Ticket #389 (closed deprecation: fixed)
subs with :method should not be entered as symbols in the namespace
|Reported by:||pmichaud||Owned by:||allison|
At the OSCON 2008 hackathon, and again at PDS, we had decided that using any of :anon, :method, or :vtable would suppress a sub from being entered as a symbol in the namespace. PDD 19 also indicates that :method implies the sub is not stored in the namespace (line 501).
To have a sub be both a method and a symbol in the namespace, one would use the :nsentry flag.
I thought this had already been completed, but I tried it just now and it doesn't work (r37066, Kubuntu 8.04 i386) -- subs with :method still appear as symbols in the namespace:
$ cat x.pir .sub 'main' :main $P0 = newclass 'XYZ' $P1 = new 'XYZ' $P1.'xyz'() $P2 = get_hll_global ['XYZ'], 'xyz' $P2($P1) .end .namespace ['XYZ'] .sub 'xyz' :method say 'XYZ::xyz' .end $ ./parrot x.pir XYZ::xyz XYZ::xyz $
A related item, equally problematic, is that placing an :anon flag on a :method sub causes it to no longer be a valid method:
$ cat y.pir .sub 'main' :main $P0 = newclass 'XYZ' $P1 = new 'XYZ' $P1.'xyz'() $P2 = get_hll_global ['XYZ'], 'xyz' $P2($P1) .end .namespace ['XYZ'] .sub 'xyz' :method :anon say 'XYZ::xyz' .end $ ./parrot y.pir Method 'xyz' not found for invocant of class 'XYZ' current instr.: 'main' pc 11 (y.pir:5) $
This is currently a blocker of sorts for processing exported subs and methods in Rakudo. I may be able to work around it in PCT, but it would be far better to have this fixed prior to 1.0 release. Indeed, I'm wondering if it got overlooked on our roadmap somehow, because it's definitely an important feature for 1.0 .