According to Ken Fox:
Is tying the only case where transmogrification hurts?
Tying is the only thing that hurts, yes -- it's the only feature that
puts a whole new personality into the body of an existing value.

(However, it's not the transmogrification that causes the pain, but
the _inability_ to transmogrify. (Perl 5's equivalent is a simple
change of the SvTYPE() and/or addition of a MAGIC, which is relatively
easy because everything above a certain SvTYPE has a common layout for
*SvANY(). No such easy way out for us.))
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.

(I think the current snapshot says assign_to(), BTW.)
BTW, I've never really been sure if extension writers are going to
be creating new scalars or new Guts.
New Scalars, I should think. FatScalar has a Guts pointer, true, but
all other Guts objects are members, not pointers. (See FatArray,
FatHash, etc.) So polymorphism doesn't have a chance to get started.

Rationale: Any given class's Guts are private. On the other hand, the
Value::Guts class will probably be documented as a convenient way to
create Guts classes with all the standard behavior(s).
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.

"You can solve any programming problem with an extra level of
indirection, except the problem of too many levels of indirection."
-- Tom C.

Chip Salzenberg - a.k.a. - <chip@valinux.com>
"I am the Lemon Zester of Destruction!" //MST3K

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 18 of 24 | next ›
Discussion Overview
groupperl6-porters @
postedOct 12, '99 at 8:32p
activeOct 18, '99 at 2:31a



site design / logo © 2019 Grokbase