Re: Tying sub arguments is rare?
[email protected] (Chip Salzenberg) Wed, 13 Oct 1999 04:28:36 -0700
| Newsgroups | perl.perl6.porters |
|---|---|
| Message-ID | <[email protected]> |
According to Ken Fox:
> Chip just made a comment to Ilya on p5p that is vaguely troublesome
> to me:
> | In Topaz, possession of a Scalar* (old: SV*) is not adequate to tie a
> | variable; you need the Scalar** (SV**) so that you can create a new
> | TiedScalar (SV with MAGIC) and make the Scalar** point to it.
>
> I understand why this is, but I think I have code that will break.
Darn.
> sv_setref_iv(ST(2), Window_Package, (IV)root_return);
>
> generated by xsubpp from the following:
>
> int
> XGetGeometry(display, d, root_return, ...
> Display * display
> Drawable d
> Window &root_return
>
> Anybody who uses & syntax in an XSUB seems to be at risk -- operations
> that change the scalar's representation will break.
Well, XSUBs are going to have to undergo some serious translation
anyway in order to work in Topaz. So it wouldn't be too hard to turn
them into the equivalent of (\$) prototypes (i.e. lvalue refs).
> Is this a problem for XSUBS, user code, both or neither?
It's a potential problem for both. You've seen the XSUB problem, but
there's also the implicit aliasing of @_ elements:
tie $_[0], 'SomePackage'; # urque
Doggone it, that's really unfortunate. If that has to keep working, I
may have to revisit large parts of the design. Grrr.
> What are the time/space trade-offs for allowing modification of sub
> arguments? Is it worth doing to improve compatibility with Perl 5?
I think we have to continue allowing simple value modification. Even
transmogrification is no issue, because it's simply an implementation
technique limited to a of the type tree (PoolScalars), and thus
irrelevant to classes that fall outside that subtree.
On the other hand, yying is a very thorny issue. We have to be able
to tie _any_ variable, even one of a type that isn't known when Perl
is compiled. Combining that with aliased @_ ... brrr.
--
Chip Salzenberg - a.k.a. - <[email protected]>
"I am the Lemon Zester of Destruction!" //MST3K