Re: Tying sub arguments is rare?
[email protected] (Ken Fox) Thu, 14 Oct 1999 15:55:39 -0400 (EDT)
| Newsgroups | perl.perl6.porters |
|---|---|
| Message-ID | <[email protected]> |
Chip Salzenberg writes:
> According to Ken Fox:
> > my $x = 1;
> > $x = foo();
> > sub foo { my $y : KenFoxScalar = 2; $y }
>
> Oh, that's easy. Scalars are allowed to be tricky, but as long as
> they're actually scalars they have to know how to do value assignment.
> (Unless they want to break that on purpose, of course.) So the author
> of KenFoxScalar provides an appropriate KenFoxScalar::copy_to(Scalar *),
> or else inherits the default one which does the obvious (:-)) things
> with final(), is(), str(), num(), etc.
Custom representations aren't very useful if they get "sliced" whenever
they get copied. Perl-wrapped constructors become impossible too. The
copy_to() method has to be able to do the moral equivalent of sv_upgrade()
which puts us back into the transmogrification quandry because (Scalar *)
isn't enough.
> > Doesn't all of this trouble go away if extension writers only create
> > new Guts?
>
> Yes, but then we're back to Perl 5's requirement of an extra level of
> indirection on EVERY SINGLE DATUM. I'm sick of that.
Huh? The core can still do ThinScalars -- just make extension writers
do FatScalar-like scalars. I have no objection to my customizations
taking an indirection penalty in exchange for simple transmogrification.
- Ken
--
Ken Fox, [email protected], (313)59-44794
------------------------------------------------------------------------
Ford Motor Company, Powertrain | "Is this some sort of trick
Analytical Powertrain Methods Department | question or what?" -- Calvin
C3P Implementation Section |