[perl #60338] [BUG] NCI segfaults with null pcc_params_signature
# New Ticket Created by Jeff Horwitz # Please include the string: [perl #60338] # in the subject line of all future correspondence about this issue. # http://rt.perl.org/rt3/Ticket/Display.html?id=60338 > changes in r32203 cause mod_parrot to segfault, as the param signature is an uninitialized string. specifically, the pcc_params_signature NCI attribute is null. not sure if this corresponds to a specific parrot test... creating the signature as a constant string appears to cause this problem, as removing PObj_constant_FLAG from src/pmc/nci.pmc:82 "fixes" the issue, though that's most certainly not a solution. chromatic thinks we need more COW: "My theory is that the JIT STRING conversion needs a Parrot_make_COW_reference." tewk has a workaround: "short-term comment tools/build/nativecall.pl:308 to disable jitted NCI" backtrace is included, now with more stack smashing! Program received signal SIGSEGV, Segmentation fault. 0x40798304 in Parrot_init_arg_sig (interp_unused=0x81b7bf8, ctx=0x832fd78, sig=0x0, ap=0x0, sti=0xb398) at src/inter_call.c:422 422 if (*sig) { (gdb) bt #0 0x40798304 in Parrot_init_arg_sig (interp_unused=0x81b7bf8, ctx=0x832fd78, sig=0x0, ap=0x0, sti=0xb398) at src/inter_call.c:422 #1 0x40797f6c in Parrot_init_arg_nci (interp=0x81b7bf8, st=0xb36c, sig=0x0) at src/inter_call.c:276 #2 0x082f6451 in ?? () #3 0x081b7bf8 in ?? () #4 0xb36c in ?? () #5 0x in ?? () #6 0x08193458 in ?? () #7 0x08310418 in ?? () #8 0x0200 in ?? () #9 0x40cdd2d8 in ?? () #10 0x082dda10 in ?? () #11 0x0832fd78 in ?? () #12 0x0001 in ?? () #13 0x in ?? () #14 0x in ?? () #15 0x in ?? () #16 0x in ?? () #17 0x081b7bf8 in ?? () #18 0x08193458 in ?? () #19 0x0100 in ?? () #20 0x407a0bc3 in key_next (interp=0x81b7bf8, key=0x82e1f4c) at src/key.c:480 #21 0x40938a6e in Parrot_NCI_invoke (interp=0x81b7bf8, pmc=0x82e1f4c, next=0x40cdd2ec) at nci.pmc:303 #22 0x40717116 in Parrot_invokecc_p (cur_opcode=0x40cdd2e4, interp=0x81b7bf8) at core.ops:475 #23 0x407cd83c in runops_slow_core (interp=0x81b7bf8, pc=0x40cdd2e4) at src/runops_cores.c:222 #24 0x4079edb9 in runops_int (interp=0x81b7bf8, offset=80) at src/interpreter.c:938 #25 0x4079f65f in runops (interp=0x81b7bf8, offs=80) at src/inter_run.c:101 #26 0x4079f904 in runops_args (interp=0x81b7bf8, sub=0x82dd7fc, obj=0x8328fd4, meth_unused=0x826cc5c, sig=0x40ad50e5 "v", ap=0xb594 "\2172\b") at src/inter_run.c:236 #27 0x4079fc96 in Parrot_run_meth_fromc_args (interp=0x81b7bf8, sub=0x82dd7fc, obj=0x8328fd4, meth=0x826cc5c, sig=0x40ad50e5 "v") at src/inter_run.c:426 #28 0x409a9042 in initialize_parents (interp=0x81b7bf8, object=0x8328fd4, all_parents=0x8329108) at class.pmc:344 #29 0x409aaf7c in Parrot_Class_instantiate (interp=0x81b7bf8, pmc=0x832923c, init=0x82c8028) at class.pmc:1131 #30 0x40736446 in Parrot_new_p_pc (cur_opcode=0x40c981b0, interp=0x81b7bf8) at pmc.ops:130 #31 0x407cd83c in runops_slow_core (interp=0x81b7bf8, pc=0x40c981b0) at src/runops_cores.c:222 #32 0x4079edb9 in runops_int (interp=0x81b7bf8, offset=2101) at src/interpreter.c:938 #33 0x4079f65f in runops (interp=0x81b7bf8, offs=2101) at src/inter_run.c:101 #34 0x4079f904 in runops_args (interp=0x81b7bf8, sub=0x82e17f8, obj=0x82c8028, meth_unused=0x0, sig=0x4043b4d5 "IP", ap=0xb7ec "\2242\b-\btz,\b<[EMAIL PROTECTED]@[EMAIL PROTECTED]<[EMAIL PROTECTED](") at src/inter_run.c:236 #35 0x4079fe56 in Parrot_runops_fromc_arglist_reti (interp=0x81b7bf8, sub=0x82e17f8, sig=0x4043b4d5 "IP", args=0xb7ec "\2242\b-\btz,\b<[EMAIL PROTECTED]@[EMAIL PROTECTED]<[EMAIL PROTECTED](") at src/inter_run.c:527 #36 0x4078995c in Parrot_call_sub_ret_int (interp=0x81b7bf8, sub=0x82e17f8, signature=0x4043b4d5 "IP") at src/extend.c:929 #37 0x4043834b in modparrot_call_sub_IP (interp=0x81b7bf8, namespace=0x82301d0 "PIR", name=0x4043af49 "post_read_request_handler", ret=0xb878, pmc=0x83294a4) at src/parrot_util.c:167 #38 0x40435a17 in modparrot_call_meta_handler (interp=0x81b7bf8, hll=0x82301d0 "PIR", hook=0x4043af49 "post_read_request_handler", ret=0xb878) at src/mod_parrot.c:233 #39 0x40435e91 in modparrot_meta_post_read_request_handler (r=0x83cab60) at src/mod_parrot.c:382
Re: [perl #60168] AutoReply: [PATCH] Refactor Junction.
Hello. After some breakages and discussions on #perl6 and #parrot I've remade this patch to proper handling boolean contexts. 1. Refactor 'junction_comparision_helper' to 'get_bool' vtable. 2. Remove 'prefix:?' and 'prefix:!' overrides. Parrot DTRT without them. 3. Replace 'junction_comparision_helper' with 'infix_junction_helper'. -- Bacek commit f15089f62abd7478573ad4145589153b5465ae92 Author: Vasily Chekalkin <[EMAIL PROTECTED]> Date: Wed Nov 5 05:23:47 2008 +1100 Refactor junctions diff --git a/languages/perl6/src/classes/Junction.pir b/languages/perl6/src/classes/Junction.pir index 9e5baca..9e1b09d 100644 --- a/languages/perl6/src/classes/Junction.pir +++ b/languages/perl6/src/classes/Junction.pir @@ -208,6 +208,60 @@ Returns a Perl representation of a junction. .return (res) .end +=item + +Override get_bool for Junction + +=cut + +.sub 'get_bool' :method :vtable +# We need to find how many values are equal. +.local pmc values +.local int num_equal +.local int count +.local int i + +values = self.'values'() +count = elements values +i = 0 +num_equal = 0 + loop: +if i >= count goto end_loop +$P0 = values[i] +$I0 = 'prefix:?'($P0) +num_equal += $I0 +inc i +goto loop + end_loop: + +# Now go by juction type. +.local int type +type = self.'!type'() +if type == JUNCTION_TYPE_ALL goto all +if type == JUNCTION_TYPE_ANY goto any +if type == JUNCTION_TYPE_ONE goto one +if type == JUNCTION_TYPE_NONE goto none + + all: +if num_equal == count goto ret_true +goto ret_false + any: +if num_equal > 0 goto ret_true +goto ret_false + one: +if num_equal == 1 goto ret_true +goto ret_false + none: +if num_equal == 0 goto ret_true +goto ret_false + + ret_true: +$P0 = get_hll_global ['Bool'], 'True' +.return($P0) + ret_false: +$P0 = get_hll_global ['Bool'], 'False' +.return($P0) +.end =back @@ -449,18 +503,6 @@ Override prefix decrement for junctions. .end -=item C - -Override not for junctions. - -=cut - -.sub 'prefix:!' :multi('Junction') -.param pmc j -$P0 = find_global 'prefix:!' -.return unary_junction_helper($P0, j) -.end - =item C @@ -500,20 +542,6 @@ Override stringification for junctions. .return unary_junction_helper($P0, j) .end - -=item C - -Override boolification for junctions. - -=cut - -.sub 'prefix:?' :multi('Junction') -.param pmc j -$P0 = find_global 'prefix:?' -.return unary_junction_helper($P0, j) -.end - - =item C Override iteration for junctions. @@ -1080,21 +1108,21 @@ Override numerical equality for junctions. .param pmc j1 .param pmc j2 $P0 = find_global "infix:==" -.return junction_comparrison_helper($P0, j1, j2, 0) +.return infix_junction_helper($P0, j1, j2, 0) .end .sub 'infix:==' :multi('Junction',_) .param pmc j .param pmc x $P0 = find_global "infix:==" -.return junction_comparrison_helper($P0, j, x, 0) +.return infix_junction_helper($P0, j, x, 0) .end .sub 'infix:==' :multi(_,'Junction') .param pmc x .param pmc j $P0 = find_global "infix:==" -.return junction_comparrison_helper($P0, j, x, 1) +.return infix_junction_helper($P0, j, x, 1) .end @@ -1108,21 +1136,21 @@ Override numerical inequality for junctions. .param pmc j1 .param pmc j2 $P0 = find_global "infix:!=" -.return junction_comparrison_helper($P0, j1, j2, 0) +.return infix_junction_helper($P0, j1, j2, 0) .end .sub 'infix:!=' :multi('Junction',_) .param pmc j .param pmc x $P0 = find_global "infix:!=" -.return junction_comparrison_helper($P0, j, x, 0) +.return infix_junction_helper($P0, j, x, 0) .end .sub 'infix:!=' :multi(_,'Junction') .param pmc x .param pmc j $P0 = find_global "infix:!=" -.return junction_comparrison_helper($P0, j, x, 1) +.return infix_junction_helper($P0, j, x, 1) .end @@ -1136,21 +1164,21 @@ Override numerical greater than for junctions. .param pmc j1 .param pmc j2 $P0 = find_global "infix:>" -.return junction_comparrison_helper($P0, j1, j2, 0) +.return infix_junction_helper($P0, j1, j2, 0) .end .sub 'infix:>' :multi('Junction',_) .param pmc j .param pmc x $P0 = find_global "infix:>" -.return junction_comparrison_helper($P0, j, x, 0) +.return infix_junction_helper($P0, j, x, 0) .end .sub 'infix:>' :multi(_,'Junction') .param pmc x .param pmc j $P0 = find_global "infix:>" -.return junction_comparrison_helper($P0, j, x, 1) +.return infix_junction_helper($P0, j, x, 1) .end @@ -1164,21 +1192,21 @@ Override numerical less than for junctions. .param pmc j1 .param pmc j2 $P0 = find_global "infix:<" -.return junction_comparrison_helper($P0, j1, j2, 0) +.return infix_junction_helper($P0, j1, j2, 0) .end .sub 'infix:<' :multi('Junction',_)
Re: [perl #60178] Commit r32189 breaks Parrot on Mac OS X 10.5.4
I pried r32189 apart to see which chunk of it breaks my compilation. The commit consists of two additions and one change. The two additions compile fine, but as soon as I make the change (attached), I can't compile. the-chunk.patch Description: Binary data
[perl #60168] [TODO] handle Junction threading in dispatch code
Hello. After some breakages and discussions on #perl6 and #parrot I've remade this patch to proper handling boolean contexts. 1. Refactor 'junction_comparision_helper' to 'get_bool' vtable. 2. Remove 'prefix:?' and 'prefix:!' overrides. Parrot DTRT without them. 3. Replace 'junction_comparision_helper' with 'infix_junction_helper'. It now passed 6 of 8 recently added tests in S03-junctions/boolen-context.t. And there is some problem with true(Junction) calls. -- Bacek commit f15089f62abd7478573ad4145589153b5465ae92 Author: Vasily Chekalkin <[EMAIL PROTECTED]> Date: Wed Nov 5 05:23:47 2008 +1100 Refactor junctions diff --git a/languages/perl6/src/classes/Junction.pir b/languages/perl6/src/classes/Junction.pir index 9e5baca..9e1b09d 100644 --- a/languages/perl6/src/classes/Junction.pir +++ b/languages/perl6/src/classes/Junction.pir @@ -208,6 +208,60 @@ Returns a Perl representation of a junction. .return (res) .end +=item + +Override get_bool for Junction + +=cut + +.sub 'get_bool' :method :vtable +# We need to find how many values are equal. +.local pmc values +.local int num_equal +.local int count +.local int i + +values = self.'values'() +count = elements values +i = 0 +num_equal = 0 + loop: +if i >= count goto end_loop +$P0 = values[i] +$I0 = 'prefix:?'($P0) +num_equal += $I0 +inc i +goto loop + end_loop: + +# Now go by juction type. +.local int type +type = self.'!type'() +if type == JUNCTION_TYPE_ALL goto all +if type == JUNCTION_TYPE_ANY goto any +if type == JUNCTION_TYPE_ONE goto one +if type == JUNCTION_TYPE_NONE goto none + + all: +if num_equal == count goto ret_true +goto ret_false + any: +if num_equal > 0 goto ret_true +goto ret_false + one: +if num_equal == 1 goto ret_true +goto ret_false + none: +if num_equal == 0 goto ret_true +goto ret_false + + ret_true: +$P0 = get_hll_global ['Bool'], 'True' +.return($P0) + ret_false: +$P0 = get_hll_global ['Bool'], 'False' +.return($P0) +.end =back @@ -449,18 +503,6 @@ Override prefix decrement for junctions. .end -=item C - -Override not for junctions. - -=cut - -.sub 'prefix:!' :multi('Junction') -.param pmc j -$P0 = find_global 'prefix:!' -.return unary_junction_helper($P0, j) -.end - =item C @@ -500,20 +542,6 @@ Override stringification for junctions. .return unary_junction_helper($P0, j) .end - -=item C - -Override boolification for junctions. - -=cut - -.sub 'prefix:?' :multi('Junction') -.param pmc j -$P0 = find_global 'prefix:?' -.return unary_junction_helper($P0, j) -.end - - =item C Override iteration for junctions. @@ -1080,21 +1108,21 @@ Override numerical equality for junctions. .param pmc j1 .param pmc j2 $P0 = find_global "infix:==" -.return junction_comparrison_helper($P0, j1, j2, 0) +.return infix_junction_helper($P0, j1, j2, 0) .end .sub 'infix:==' :multi('Junction',_) .param pmc j .param pmc x $P0 = find_global "infix:==" -.return junction_comparrison_helper($P0, j, x, 0) +.return infix_junction_helper($P0, j, x, 0) .end .sub 'infix:==' :multi(_,'Junction') .param pmc x .param pmc j $P0 = find_global "infix:==" -.return junction_comparrison_helper($P0, j, x, 1) +.return infix_junction_helper($P0, j, x, 1) .end @@ -1108,21 +1136,21 @@ Override numerical inequality for junctions. .param pmc j1 .param pmc j2 $P0 = find_global "infix:!=" -.return junction_comparrison_helper($P0, j1, j2, 0) +.return infix_junction_helper($P0, j1, j2, 0) .end .sub 'infix:!=' :multi('Junction',_) .param pmc j .param pmc x $P0 = find_global "infix:!=" -.return junction_comparrison_helper($P0, j, x, 0) +.return infix_junction_helper($P0, j, x, 0) .end .sub 'infix:!=' :multi(_,'Junction') .param pmc x .param pmc j $P0 = find_global "infix:!=" -.return junction_comparrison_helper($P0, j, x, 1) +.return infix_junction_helper($P0, j, x, 1) .end @@ -1136,21 +1164,21 @@ Override numerical greater than for junctions. .param pmc j1 .param pmc j2 $P0 = find_global "infix:>" -.return junction_comparrison_helper($P0, j1, j2, 0) +.return infix_junction_helper($P0, j1, j2, 0) .end .sub 'infix:>' :multi('Junction',_) .param pmc j .param pmc x $P0 = find_global "infix:>" -.return junction_comparrison_helper($P0, j, x, 0) +.return infix_junction_helper($P0, j, x, 0) .end .sub 'infix:>' :multi(_,'Junction') .param pmc x .param pmc j $P0 = find_global "infix:>" -.return junction_comparrison_helper($P0, j, x, 1) +.return infix_junction_helper($P0, j, x, 1) .end @@ -1164,21 +1192,21 @@ Override numerical less than for junctions. .param pmc j1 .param pmc j2 $P0 = find_global "infix:<" -.return junction_compar
[perl #60350] [TODO] default __get_string method
# New Ticket Created by Chris Dolan # Please include the string: [perl #60350] # in the subject line of all future correspondence about this issue. # http://rt.perl.org/rt3/Ticket/Display.html?id=60350 > If you "say $x" on an $x that is an instance of class Foo that lacks stringification via __get_string(), then you get a crash with the error "get_string() not implemented in class Foo". I propose that Perl6Object get a fallback __get_string method that returns simply the class name and a unique identifier (maybe a pointer value). While unaesthetic, that fallback would prevent the program from just crashing and (as a bonus) would reveal the class name. This approach has precedent in Perl5, Java, and other languages.
[perl #48016] [DEPRECATED] store_global opcode
On Sat Dec 01 14:29:03 2007, coke wrote: > =item B > > There are several variants of some of the above ops; all are deprecated, > and are replaced by the ops {set,get}_[hll,root]_global. See also > http://www.parrotcode.org/docs/ops/var.html. DEPRECATED.pod also says that the global keyword in PIR is going away with the removal of the store_global/find_global opcodes. We should probably remove ".global" at the same time; seems to be a leftover in IMCC's grammar. -- Will "Coke" Coleda
Re: .perl and other methods on Junctions?
On Tue, Nov 04, 2008 at 01:33:09PM -0600, Patrick R. Michaud wrote: : Consider the code: : : my $x = 3 | 'foo'; : my $y = $x.perl; : : : Does $y end up as a junction of strings or as a single string? I think it may not actually matter much, if subsequent stringification of the junction produces a result with correct Perl syntax. : Asking more directly, does .perl autothread over a Junction? : If .perl does not autothread, then is there some way of knowing : which methods autothread and which do not? I think it would depend entirely on whether the Junction class defined method .perl, or relied on the authothreading implementation triggered by Object recognizing that it was handed a Junction. But it seems to me that if stringification of a junction returns a correct .perlish syntax, it's probably better to just let that happen lazily, on the assumption someone might want .perl to autothread for some reason, perhaps because .perl performs some kind of useful canonicalization prior to comparison. So I think the actual choice is driven by the fact that Str(Junction) is defined to work like you'd expect .perl to do if .perl did it, which it doesn't... : (The question of method autothreading over junctions came up at : the OSCON 2008 hackathon, but I don't know that it was ever : resolved. If it was and I've just forgotten or overlooked the : resolution, I'll be happy to have it pointed out to me.) Well, at the time we thought there might need to be some kind of VAR-like JUNCTION macro to give access to the Junction object, but if the decision is just based on whether Junction defines the method or not, that's not really necessary. And with this semantics, it's also no problem going the other way. If method .junk is defined in Junction, you can still force it to autothread by saying $junction.Object::junk(). Larry
Re: [perl #48014] [DEPRECATED] PMC union struct
On Wednesday 22 October 2008 09:28:38 Bernhard Schmalhofer via RT wrote: > Does this mean that this ticket can be closed and the deprecation item > in DEPRECATED.pod be removed? Not until we apply this patch and all tests still pass. -- c === include/parrot/pobj.h == --- include/parrot/pobj.h (revision 32390) +++ include/parrot/pobj.h (local) @@ -55,12 +55,6 @@ #define PObj_bufstart(pmc)(pmc)->cache._b._bufstart #define PObj_buflen(pmc) (pmc)->cache._b._buflen -#define PMC_struct_val(pmc) (pmc)->cache._ptrs._struct_val -#define PMC_pmc_val(pmc) (pmc)->cache._ptrs._pmc_val -#define PMC_int_val(pmc) (pmc)->cache._i._int_val -#define PMC_int_val2(pmc) (pmc)->cache._i._int_val2 -#define PMC_num_val(pmc) (pmc)->cache._num_val -#define PMC_str_val(pmc) (pmc)->cache._string_val /* See src/gc/resources.c. the basic idea is that buffer memory is set up as follows:
Re: "::" in namespaces
Aha, this was already reported as [perl #60358] Rakudo doesn't recognize grammars with :: in the name I added my thoughts to that ticket. Chris On Nov 5, 2008, at 12:36 AM, Chris Dolan wrote: Replying to myself: I think the flaw is in my use of "PDF::Grammar::literal_string" as a method pointer. This worked fine when it was "PDF__Grammar::literal_string", but now the following PIR: get_hll_global $P108, ["PDF";"Grammar"], "literal_string" is returning undef. The answer appears to be that the PIR for PDF/ Grammmar.pm includes this: .namespace ["PDF::Grammar"] .sub "literal_string" :method instead of .namespace ["PDF";"Grammar"] .sub "literal_string" :method So, does that mean teaching PGE/Exp.pir about double-colon separators? Or does namespace separator need to be some sort of compreg flag? Chris On Nov 4, 2008, at 9:10 PM, Chris Dolan wrote: Thanks to Jonathan for working on the :: bug. I'm still having problems, however. The code below worked before I switched all of my "__" class separators to "::". I'm not sure how to tell whether it's failing to find my .pm (I moved the .pm from lib/ PDF__Grammar__Actions.pm to lib/PDF/Grammar/Actions.pm at the same time) or if there's a lingering flaw in the namespace code. What SVN revision did that change go in? In r32354 on Mac 10.4 ppc I'm getting: invoke() not implemented in class 'Undef' The Perl6 code that triggers that looks like this: method is_string(Str $src, Str $expected, Str $msg) { my $method = PDF::Grammar::literal_string; my $m = $src.$method(:action(PDF::Grammar::Actions.new)); is($m, $expected, $msg) || diag("got: $m, expected: $expected"); } and the corresponding PIR is: find_lex $P111, "$src" unless_null $P111, vivify_19 new $P111, "Perl6Scalar" vivify_19: get_hll_global $P112, ["PDF";"Grammar"], "Actions" unless_null $P112, vivify_20 new $P112, "Failure" vivify_20: $P113 = $P112."new"() $P114 = $P111.$P110($P113 :named("action")) # <-- this line fails Thanks, Chris
Re: "::" in namespaces
On Tue, Nov 04, 2008 at 09:10:02PM -0600, Chris Dolan wrote: > The Perl6 code that triggers that looks like this: > >method is_string(Str $src, Str $expected, Str $msg) { > my $method = PDF::Grammar::literal_string; ... just a point of syntax (which probably doesn't resolve the issue you're having), but "PDF::Grammar::literal_string" above gets treated like a listop call instead of a method reference. To get the method itself, we probably need an ampersand in front. I'm still looking into the other details of the problem you're having. Pm
Re: "::" in namespaces
On Nov 5, 2008, at 9:41 PM, Patrick R. Michaud wrote: On Tue, Nov 04, 2008 at 09:10:02PM -0600, Chris Dolan wrote: The Perl6 code that triggers that looks like this: method is_string(Str $src, Str $expected, Str $msg) { my $method = PDF::Grammar::literal_string; ... just a point of syntax (which probably doesn't resolve the issue you're having), but "PDF::Grammar::literal_string" above gets treated like a listop call instead of a method reference. To get the method itself, we probably need an ampersand in front. I'm still looking into the other details of the problem you're having. Pm Actually, I just submitted a one-line patch to the Rakudo actions.pm via RT 60358 that solves this problem. I got a big boost from the namespace fix Jonathan did this week. It sure behaves like a method reference... Anyway, I didn't actually *want* the method. Rakudo wouldn't let me do the perl5ish external- package-method-call syntax like this: my $m = $src.PDF::Grammar::literal_string(...); so I had to break it up into two statements my $method = PDF::Grammar::literal_string; my $m = $src.$method(...); which works. I can't explain why I didn't need the ampersand. Lucky, I guess. It'll probably break when someone fixes that bug. :-) Chris
Re: [perl #57864] Calling a token "text" in rakudo makes matching fail
On Fri, Oct 31, 2008 at 08:47:09PM -0700, Chris Dolan via RT wrote: > It seems to be Regex.pir that is taking all of the invocations. I have > discovered that, beyond , I cannot create tokens/rules named > "null", "ws", etc. The latter is particularly problematic in writing > parsers in Perl6. The following simple example shows the failure: > > grammar WSOverride { >token TOP { <.ws> }; >token tok_foo { foo }; >token tok_bar { bar }; >token ws { [ \h | \v | '%' ]+ }; > } > > ok('foo bar' ~~ WSOverride::TOP); # succeeds > ok("foo\nbar" ~~ WSOverride::TOP); # succeeds > ok("foo%%%\nbar" ~~ WSOverride::TOP); # fails First, note that C< 'foo bar' ~~ WSOverride::TOP > isn't really the correct syntax for invoking a rule -- but the synopses don't really specify what the correct syntax is yet. At the moment we do know that it's not likely to be C< 'foo' ~~ Grammar::rule >. Beyond that, the problem appears to be that Rakudo is not presently creating its grammars properly -- it appears to be deriving them directly from Any instead of from a PGE grammar class of some sort. As a result, inheritance and method dispatch don't seem to be working quite properly, and we'll need to get that fixed. Pm
Re: [perl #60350] [TODO] default __get_string method
On Tue, Nov 04, 2008 at 10:28:26PM -0800, Chris Dolan wrote: > I propose that Perl6Object get a fallback __get_string method that > returns simply the class name and a unique identifier (maybe a > pointer value). Now added in r32373. Here's an example: $ cat x class Foo { method speak() { say 'hello' } } say Foo.new(); $ ./parrot perl6.pbc x Foo<0xb73ac540> $ As an added bonus, per Synopsis 13 one can also define a C method in a class to specify how it stringifies: $ cat y class Bar { method Str() { return 'world' } } say "hello { Bar.new() }"; $ ./parrot perl6.pbc x hello world $ Closing ticket. Thanks! Pm
Re: Known Bug in Rakudo?
On Thu, Oct 30, 2008 at 08:03:17AM -0700, Ovid wrote: > This code: > > class Point { > has $.x is rw; > has $.y is rw; > > method get_string () { > return "<$.x, $.y>"; > } > } > > my Point $point .= new( :x<1.2>, :y<-3.7> ); > say $point.x; > say $point; > > Generates this output: > > 1.2 > get_string() not implemented in class 'Point' Now fixed in r32373. The "get_string() not implemented ..." message actually comes from Parrot -- in Perl 6 we define stringification using the C method (see S13): $ cat point.pl class Point { has $.x is rw; has $.y is rw; method Str() { return "<$.x, $.y>"; } } my Point $point .= new( :x<1.2>, :y<-3.7> ); say $point.x; say $point; $ ./parrot perl6.pbc point.pl 1.2 <1.2, -3.7> $ This problem was also addressed in RT #60350 (now resolved). Hope this helps, and thanks! Pm
Numify
In "[perl #60350] [TODO] default __get_string method", Patrick added a default Object.Str() that classes can override to get custom stringification. Formerly, you could do that only by defining a method named __get_string(). Currently, you can overload number context by creating a __get_number () method and boolean context via __get_bool(). Should there be an analogous Num() and Bool() method on Object? Would it Num() return 0 by default? And a default Bool() that returns True? The Failure class would override negatively, and the container classes could override Num() Is this making life harder by making two methods to override, Str() and __get_string, Num() and __get_number(), Bool() and __get_bool()? Maybe instead Str(), Bool(), Num() should be magic and automatically get a :vtable tag via actions.pm? Then maybe we could drop the __get_* counterparts? I'd be happy to implement if someone would comment on the best approach. Chris