On Sat, Oct 21, 2006 at 07:10:21PM +0200, Leopold Toetsch wrote:
> Am Donnerstag, 19. Oktober 2006 23:19 schrieb Patrick R. Michaud:
> > .HLL 'pge', ''
> >
> > .sub __onload :load
> > $P0 = newclass 'Exp'
> [...]
> > $P0 = subclass 'Exp', 'Closure'
> > # ...
> > .end
> > [...]
> > So, this brings me to my question: What is the official
> > "best practice" pattern for HLLs to create their own classes
> > such that we avoid naming conflicts with existing classes
> > in Parrot and other HLLs?
>
> .HLL 'pge', ''
>
> is implying the toplevel namespace ['pge']. The C<newclass 'Exp'> therfore is
> created as ['pge';'Exp']. But you are subclassing that to an existing
> (because unqualified) 'Closure' name.
>
> IMHO this should look like this:
>
> .HLL 'pge', ''
> ...
> cl = newclass 'Exp' # ['pge'; 'Exp']
> ...
> .namespace ['Exp'] # ['pge'; 'Exp']
> ...
> scl = subclass 'Exp', ['Exp'; 'Closure'] # ['pge'; 'Exp'; 'Closure']
> ...
I strongly disagree. I don't think that a subclass should have to
be named as a sub-namespace of its parent class.
Put another way, if Num isa Object, and Int isa Num,
does that mean that I would have to do...?
.hll 'perl6', ''
$P0 = newclass 'Object'
$P1 = subclass 'Object', ['Object'; 'Num']
$P2 = subclass ['Object'; 'Num'], ['Object'; 'Num'; 'Int']
Normally I would expect 'Object', 'Int', and 'Num' to have their
own top-level namespaces within the HLL namespace, and not require
classnames to always include the list of parent classes.
Pm