On Fri, 2004-05-14 at 10:48, Austin Hastings wrote:

> > my int $i = ...;
> 
> Right. This goes back to the notion that lowercase basic types (int,
> str, bool) are "storage efficient" and therefore cannot contain values
> outside the domain, like C<undef>.

Nope, not at all.

You can say:

        my int $i = $complex_high_level_cool_object;

any time you like, and that should compile clean (unless the object does
something special at compile-time to exclude such a conversion from even
being attempted). 

The question I have is: how do classes control their conversion? In C++
you can overload the casting operator for any time and/or define a
constructor for the receiving type.

I can imagine how you would define the constructor on the receiving type
in Perl 6, but there's no "casting" syntax in Perl 6. Should we pretend
there is for purposes of defining a conversion and allow:

        class foo {
                ...
                sub prefix:IO::Socket(foo $f) returns(IO::Socket) {...}
        }

or did Larry mention a way to define a converter and I missed it?

-- 
Aaron Sherman <[EMAIL PROTECTED]>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback


Reply via email to