On 1/19/06, Juerd <[EMAIL PROTECTED]> wrote:
> Rob Kinyon skribis 2006-01-19 16:10 (-0500):
> > There are no references in Perl6.
> I have to admit, though, that I've never seen this statement, or
> anything implying it. It's entirely new to me.
>
> Is your Perl the same as that of other people on this list? :)
There are no references in Perl6 in the way Perl5 conceives of references.
> Perl still has non-object types. They may represent objects internally,
> but they work differently from what we've historically been calling
> objects. Especially in assignment, the differences are huge, because an
> object is considered a reference, while "real" scalars, arrays and
> hashes evaluate to (a list of) their values, or a useful representation
> (like the number of elements) when used in non-OO fashion.
No. Objects are *NOT* considered references in most languages other
than Perl5. Even in C++, the least OO language that could be
considered OO, you can have non-reference objects.
I'd say "learn Ruby to know what OO is", but I happen to know you
already know a nearly-pure OO language - Javascript. Every single
'thing' in JS is an object - you can hang methods off of a string
literal or a number. Most objects in JS aren't references.
> > &bless was a brilliant idea for Perl5. It's wrong for Perl6.
>
> I think it's needed to be able to convert Perl 5 code
> semi-automatically.
>
> But you have probably thought about this more than I, so I'll ask you:
> what's the alternative?
Well, there's two scenarios - you either run your P5 code using Ponie
or you attempt to use Larry's "Wondrous Machine of Translation".
Me, I choose the former. Now, I don't worry about how objects are
mediated between languages - Ponie and Parrot have to do that for me.
And, before you start worrying, this is a feature that was planned
into Parrot from Day 1. Ruby and Python and Perl6 all have to
interoperate, including inheritance from each others' classes. Perl5
<-> Perl6 will be no different.
But, if you must use the WMoT, then I suspect the following will happen:
1) The WMoT notices your use of &bless and marks that package as a
class and that method as a constructor.
2) It creates a Perl6 class for your use, noting the accesses into
the Perl5 reference that you used and calling those attributes.
3) It then creates your BUILD() method, putting all the non-bless
components of your new() into it.
That's it. No &bless in Perl6 needed.
Rob