Am Donnerstag, 19. Oktober 2006 23:19 schrieb Patrick R. Michaud:
> So, here's the revised version of the code to create
> the classes:
>
>     .HLL 'pge', ''
>
>     .sub __onload :load
>         $P0 = newclass 'Exp'
  [...]
>         $P0 = subclass 'Exp', 'Closure'
>         # ...
>     .end
>
> This code fails when run from parrot, because Parrot seemingly
> already has a class named 'Closure':
>
>     $ ./parrot ns.pir
>     Class Closure already registered!
>     current instr.: '__onload' pc 19 (ns.pir:9)
>     $
>
> 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']
  ...

leo

et ceterum censeo ... that .HLL and namspaces should be orthogonal concepts

Reply via email to