chromatic wrote:

What should the syntax for creating new objects be? That is, if I define an object with its methods in the namespace [ 'PAST'; 'Node' ], how do I create a new instance of that class?

        .local pmc node
        node = new ???

Thinking a bit more about it (and discussing this issue with pmichaud) on #parrot - it seems that we really want hierarchical class names too, the more that a Perl6 class isa NameSpace too.

That means:

* newclass, subclass, getclass, and new opcodes need variants that take a Key PMC, e.g.

   cl1 = newclass ['PAST'; 'Node']
   cl2 = newclass ['POST'; 'Node']

and

   obj = new ['PAST'; 'Node']

* the class_hash will be a NameSpace hash instead of a plain 'flat' hash

What do folks think?

-- c

leo
.sub main :main
    .local pmc v, m, o
    create_base()
    m = find_global 'PAST', 'create_classes'
    m()
    v = new 'PAST_Val'
    o = new 'PAST_Op'
.end

.sub create_base
    .local pmc c1
    c1 = newclass 'PAST'
.end

.namespace ['PAST']

.sub create_classes
    .local pmc c1, c2
    c1 = newclass 'PAST_Val'
    c2 = newclass 'PAST_Op'
.end

.namespace ['PAST'; 'PAST_Val']

.sub __init :method
    print "PAST_Val init\n"
.end

.namespace ['PAST'; 'PAST_Op']

.sub __init :method
    print "PAST_Op init\n"
.end

.namespace ['POST']

# more classes

.namespace ['POST'; 'POST_Val']

Reply via email to