# New Ticket Created by "Carl Mäsak" # Please include the string: [perl #77322] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=77322 >
>From <http://use.perl.org/~JonathanWorthington/journal/39856>: ] Added handling of the grammar package declarator back in. Now the ] "inherit from Grammar by default and not Any" stuff is just done by ] us having a metaclass for grammars - GrammarHOW - that subclasses ] the metaclass for classes - ClassHOW. It simply overrides the ] compose method (what we call when we're finished defining a package) ] and checks if there are any explicit parents, and if not adds Grammar ] as a parent, then delegates up to the superclass to do the rest of the work. <masak> rakudo: class A {}; grammar G is A { regex TOP { foo } }; G.parse("foo") <p6eval> rakudo 90637b: OUTPUT«Method 'parse' not found for invocant of class '' [...] <masak> I know, that's a bit of "doctor, it hurts when I do this"... <moritz_> masak: I'd say it's a bug. 'grammar' should add Grammar to the list of its parents, unless one of the explicit parents is Grammar already <moritz_> at least I think that's what it should do. <masak> oh, good. * masak submits rakudobug <moritz_> and I know where to fix it <moritz_> src/metamodel/GrammarHow.pir around line 41 <jnthn> :-) <jnthn> Yes, that's HOW. <moritz_> if it were written in Perl 6, I'd say if none(@parents>>.isa(Grammar)) { $P0.add_parent(Grammar, $P0) } <jnthn> It'll be written in NQP at some point. <moritz_> jnthn: how hard would it be to rewrite it now? <jnthn> moritz_: Probably quite easy. <jnthn> Though a bit messy, since for now you'd still need pir::foo I guess