Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Object instantiation

8 views
Skip to first unread message

Dan Sugalski

unread,
Oct 21, 2003, 10:14:03 AM10/21/03
to perl6-i...@perl.org
After thinking about this a bit, it became glaringly obvious that the
right way to instantiate an object for class "Foo" is to do:

new P5, .Foo

Or whatever the constant value assigned to the Foo class upon its creation
is. When a class is created, it should be assigned a number, and for most
things PMC-only classes or full-on HLL classes should behave identically.
Duh.

One more thing down--now to actually make it work out...

Dan

Leopold Toetsch

unread,
Oct 21, 2003, 10:24:47 AM10/21/03
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski <d...@sidhe.org> wrote:
> After thinking about this a bit, it became glaringly obvious that the
> right way to instantiate an object for class "Foo" is to do:

> new P5, .Foo

> Or whatever the constant value assigned to the Foo class upon its creation
> is. When a class is created, it should be assigned a number, and for most
> things PMC-only classes or full-on HLL classes should behave identically.

Yep. The question does arise, if which range class enums are? Intermixed
with enum_class_<pmc> numbers?

And - what about:

typeof S0, P0 <=> classname S0, P0

(IMHO the HLL compiler can't always know, which op to use)

And the classname of objects vs the classname of classes (the classname
PMC is in different array slots).

> Dan

leo

Dan Sugalski

unread,
Oct 21, 2003, 10:53:55 AM10/21/03
to Leopold Toetsch, perl6-i...@perl.org
On Tue, 21 Oct 2003, Leopold Toetsch wrote:

> Dan Sugalski <d...@sidhe.org> wrote:
> > After thinking about this a bit, it became glaringly obvious that the
> > right way to instantiate an object for class "Foo" is to do:
>
> > new P5, .Foo
>
> > Or whatever the constant value assigned to the Foo class upon its creation
> > is. When a class is created, it should be assigned a number, and for most
> > things PMC-only classes or full-on HLL classes should behave identically.
>
> Yep. The question does arise, if which range class enums are? Intermixed
> with enum_class_<pmc> numbers?

Yes, intermixed. I added support a while back to pass in the class number
to a PMC class being initialized for this very reason. The compiled-in
PMCs get fixed numbers at the beginning because it's easiest, and things
get referenced symbolically from there.

> And - what about:
>
> typeof S0, P0 <=> classname S0, P0
>
> (IMHO the HLL compiler can't always know, which op to use)

At this point they're the same thing, I think. I'll need to think on it a
bit.

> And the classname of objects vs the classname of classes (the classname
> PMC is in different array slots).

Last I knew there was something of a fight over what class a class is in.
At the moment I'm going to ignore the heck out of things and let the
language folks fight over it some more.

Dan

Jeff Clites

unread,
Oct 21, 2003, 11:11:56 AM10/21/03
to Dan Sugalski, perl6-i...@perl.org
On Oct 21, 2003, at 7:14 AM, Dan Sugalski wrote:

> After thinking about this a bit, it became glaringly obvious that the
> right way to instantiate an object for class "Foo" is to do:
>
> new P5, .Foo
>
> Or whatever the constant value assigned to the Foo class upon its
> creation
> is. When a class is created, it should be assigned a number, and for
> most
> things PMC-only classes or full-on HLL classes should behave
> identically.
> Duh.

That makes sense. What I keep wondering is what about things with the
semantics of Perl5, in which new objects aren't instantiated
directly--already-allocated things later become associated with a
class. This doesn't seem quite like a case of morphing, since for
instance a Perl array can be blessed into a class, but it's still a
Perl array.

JEff

0 new messages