develooper Front page | perl.perl6.porters | Postings from October 1999

Tying sub arguments is rare?

Thread Next
From:
Ken Fox
Date:
October 12, 1999 13:32
Subject:
Tying sub arguments is rare?
Message ID:
199910122032.QAA01287@mailfw2.ford.com
Chip just made a comment to Ilya on p5p that is vaguely troublesome
to me:

| > > Would you consider passing \$fido to ALLOCATE?  It would avoid the
| > > need for some fairly serious pain in Topaz.
| ...
| 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.
Here's an example:

  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. I've never really
liked the idea of modifying (or worse, transmogrifying ;) apparent
pass-by-value arguments (another victim of Pascal?), but it is deeply
ingrained in Perl.

Is this a problem for XSUBS, user code, both or neither?

What are the time/space trade-offs for allowing modification of
sub arguments? Is it worth doing to improve compatibility with Perl 5?

- Ken

-- 
Ken Fox, kfox@ford.com, (313)59-44794
------------------------------------------------------------------------
Ford Motor Company, Powertrain           | "Is this some sort of trick
Analytical Powertrain Methods Department |  question or what?" -- Calvin
C3P Implementation Section               |

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About