**{x,y} quantifier
(I'm just studying the intricacies of Perl 6, so please correct me if i say something stupid or if this has already been discussed before.) I was looking for the Perl 6 equivalent of "aaa" =~ /a{1,3}/ and finally found that it's "aaa" ~~ /a**{1 .. 3}/ This looked rather weird, so i asked on IRC what is the mnemonic for it: http://moritz.faui2k3.org/irclog/out.pl?channel=perl6;date=2007-06-29#id_l602 I got the reply that it is similar to exponentiation of variables in math: a ** 5 == a * a * a * a * a == a It makes sense after it is explained and i do like the rationalization of the range as a list-like range, instead of the comma, but the ** syntax is rather ugly to my taste. Seeing that the ** quantifier is not yet implemented anyway, I thought what could replace it, and the best i could find was <1 .. 3>. My rationale is this: * It looks clean. * It the chapter about Extensible metasyntax (<...>) in S05 most paragraphs begin by "A leading X means yadda yadda", where X can be: * whitespace * alphabetic character (not alphanumeric!) * ? $ :: @ % { & [ + - . ! ~~ ... so numbers are not covered. * As a side effect, * is a shortcut for <0 .. Inf>, + is a shortcut for <1 .. Inf>, ? * is a shortcut for <0 .. 1>. * The ? of non-greediness can come before the closing > - <1 .. 3 ?> Any comments? -- Amir Elisha Aharoni my band: http://www.myspace.com/tzabari/ my blog: http://aharoni.wordpress.com/
Re: **{x,y} quantifier
On 7/1/07, Amir E. Aharoni <[EMAIL PROTECTED]> wrote: I got the reply that it is similar to exponentiation of variables in math: a ** 5 == a * a * a * a * a == a It makes sense after it is explained and i do like the rationalization of the range as a list-like range, instead of the comma, but the ** syntax is rather ugly to my taste. Seeing that the ** quantifier is not yet implemented anyway, I thought what could replace it, and the best i could find was <1 .. 3>. My rationale is this: * It looks clean. * It the chapter about Extensible metasyntax (<...>) in S05 most paragraphs begin by "A leading X means yadda yadda", where X can be: * whitespace * alphabetic character (not alphanumeric!) * ? $ :: @ % { & [ + - . ! ~~ ... so numbers are not covered. * As a side effect, * is a shortcut for <0 .. Inf>, + is a shortcut for <1 .. Inf>, ? * is a shortcut for <0 .. 1>. * The ? of non-greediness can come before the closing > - <1 .. 3 ?> Your argument seems to be "<1..3> is cleaner-looking to me, and it is possible to implement". While that second constraint is always an important one, cleanliness is not the highest concern. There's more to beauty than what the eye can see. I believe that **{1..3} was at one point spelled <1,3>. The rather glaring inconsistency of that is that <>-constructions are always assertions, never modifiers. That is to say, in the rest of the regex design, whenever you see , it never depends on what comes before it. Another important loss if we were to go with <1..3> would be the ability to have runtime-dependent ranges; e.g.: / ($ntimes) x**{$ntimes} / You also lose the ** exponentiation mnemonic, which I found pretty on the inside :-). You also lose the *-like (because it really is just a special kind of *) mnemonic. I think the losses are too great to warrant such a change just for the purpose of visual appeal. Luke
Re: **{x,y} quantifier
> please correct me if > i say something stupid or if this has already been discussed before.) Another important loss if we were to go with <1..3> would be the ability to have runtime-dependent ranges; e.g.: / ($ntimes) x**{$ntimes} / That's exactly what i meant by "something stupid". Thanks - my bad.
Re: **{x,y} quantifier
On 7/1/07, Amir E. Aharoni <[EMAIL PROTECTED]> wrote: > > please correct me if > > i say something stupid or if this has already been discussed before.) > Another important loss if we were to go with <1..3> would be the > ability to have runtime-dependent ranges; e.g.: > > / ($ntimes) x**{$ntimes} / That's exactly what i meant by "something stupid". That's quite alright, because both interpretations of that sentence were valid :-). I meant: / $ntimes := (\d+) x**{$ntimes} / Luke
Named captures (was: **{x,y} quantifier)
On 01/07/07, Luke Palmer <[EMAIL PROTECTED]> wrote: On 7/1/07, Amir E. Aharoni <[EMAIL PROTECTED]> wrote: > > > please correct me if > > > i say something stupid or if this has already been discussed before.) > > > Another important loss if we were to go with <1..3> would be the > > ability to have runtime-dependent ranges; e.g.: > > > > / ($ntimes) x**{$ntimes} / > > That's exactly what i meant by "something stupid". That's quite alright, because both interpretations of that sentence were valid :-). I meant: / $ntimes := (\d+) x**{$ntimes} / Luke Funny - how did it make sense to me the first time around? :) This prompted me to re-read the parts about Subpattern captures and Aliasing in S05, and i've got to say that it's *extreme* TMTOWTDI. I'm happy about it, 'cause i've been wishing for named captures for a long time, but i'm not sure that i understand it in your example completely. The examples of := usage in S05 seem to have notation such as this: $ := (\d+) Is $ntimes supposed to be a predefined scalar variable (my $ntimes)? Or a regex variable? I'm getting confused ...
Re: Named captures (was: **{x,y} quantifier)
On 7/1/07, Amir E. Aharoni <[EMAIL PROTECTED]> wrote: On 01/07/07, Luke Palmer <[EMAIL PROTECTED]> wrote: > / $ntimes := (\d+) x**{$ntimes} / The examples of := usage in S05 seem to have notation such as this: $ := (\d+) Yes, that is correct. I've been away from the Perl 6 community for quite some time... it seems that not only have I not kept up with the latest changes, but my brain is suffering bit rot. Human brains seem to have some sort of LRU garbage collector... Luke
[perl #43463] [BUG] Parrot Bug Summary "Requestors with most open tickets" doesn't DWIM
# New Ticket Created by James Keenan # Please include the string: [perl #43463] # in the subject line of all future correspondence about this issue. # http://rt.perl.org/rt3/Ticket/Display.html?id=43463 > --- osname= linux osvers= 2.6.15 arch= i386-linux-thread-multi cc= cc --- Flags: category=utilities severity=low ack=no --- The weekly Parrot bug summary (http://rt.perl.org/rt3/NoAuth/parrot/Overview.html) contains a section entitled "Requestors with most open tickets". When I click on the link in this section corresponding to my name, I would expect to be taken to a page holding a list of tickets I originated which are still open. But all I get is something like this: Id Subject Created Last Update (0 tickets listed) I should get a listing of 68 tickets. Am I doing something wrong or is this a bug? kid51 --- Summary of my parrot 0.4.13 (r19514) configuration: configdate='Sun Jul 1 02:10:47 2007 GMT' Platform: osname=linux, archname=i686-linux jitcapable=1, jitarchname=i386-linux, jitosname=LINUX, jitcpuarch=i386 execcapable=1 perl=/usr/local/bin/perl Compiler: cc='cc', ccflags=' -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE', Linker and Libraries: ld='cc', ldflags=' -L/usr/local/lib', cc_ldflags='', libs='-lnsl -ldl -lm -lcrypt -lutil -lpthread -lrt' Dynamic Linking: share_ext='.so', ld_share_flags='-shared -L/usr/local/lib -fPIC', load_ext='.so', ld_load_flags='-shared -L/usr/local/lib -fPIC' Types: iv=long, intvalsize=4, intsize=4, opcode_t=long, opcode_t_size=4, ptrsize=4, ptr_alignment=1 byteorder=1234, nv=double, numvalsize=8, doublesize=8 --- Environment: HOME =/home/jimk LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH =/usr/local/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/mysql/bin:/home/jimk/bin:/home/jimk/bin/perl SHELL =/bin/bash
About the headerizer
http://www.perlfoundation.org/parrot/index.cgi?headerizer I've started this page as my brain dump of ideas until I get it into a proper .pod file. Please add to it, or ask questions on the page, as you see fit. xoxo, Andy -- Andy Lester => [EMAIL PROTECTED] => www.petdance.com => AIM:petdance
Re: [svn:parrot] r19520 - in trunk: compilers/imcc config/gen/makefiles src
On Sunday 01 July 2007 07:38:02 [EMAIL PROTECTED] wrote: > Author: petdance > Date: Sun Jul 1 07:38:01 2007 > New Revision: 19520 > > Modified: >trunk/compilers/imcc/imc.h >trunk/compilers/imcc/imcparser.c >trunk/compilers/imcc/main.c >trunk/compilers/imcc/parser_util.c >trunk/compilers/imcc/pbc.c >trunk/config/gen/makefiles/root.in >trunk/src/string.c > > Log: > adding restrictions throughout IMCC as I track down the valgrind errors In the interest of "What should other people look out for to prevent reoccurrences", which valgrind errors and what's the fix? -- c
A problem about IPC::Open2
Hello, I'm a beginner of the PERL language and I have troubles in understanding a PERL program these days. Actually I've been confused for a long time.I hope you can look into this program and point out the problem for me:) The program is in the attachment.It's a bit long , but the error occured at the very beginning. Here is the description: It's about the use of "IPC::Open2". In line 60 of file "SearnShell.pl" a pipe is opened. The program executes correctly until line 745 of file "SearnShell.pl" which is "my $result = ;". "$result" is supposed to receive a value from another end of the pipe but it receives nothing...The other end of pipe is in line 17 of file "Control.pm" which is " while (<>) { ". It is supposed to receive the input from line 744 of file "SearnShell.pl" and do some comparing works and then print "OK\n" . Unfortunately, " while (<>) " receives nothing...As a result the whole thing can not work rightly. So I guess the problem is " while (<>) " in line 17 of file "Control.pm" receives nothing . I don't konw why it happens and really hope you can get me out of this confusion sincerely, becky SearnShell_v0.1.rar Description: Binary data
[perl #43453] [PATCH] typos in docs/configuration.pod
# New Ticket Created by Bob Wilkinson # Please include the string: [perl #43453] # in the subject line of all future correspondence about this issue. # http://rt.perl.org/rt3/Ticket/Display.html?id=43453 > Hello A couple of typos in docs/configuration.pod. [EMAIL PROTECTED]:~/src/parrot/docs$ svn diff configuration.pod Index: configuration.pod === --- configuration.pod (revision 19512) +++ configuration.pod (working copy) @@ -71,7 +71,7 @@ Templates for to be generated files usually have the extension '.in'. There is variable substitutes and funny macros like 'CONDITIONED_LINE' and -INVERSE_CONDITIONED_LINE'. +'INVERSE_CONDITIONED_LINE'. =head2 Prompt or Probe? @@ -152,7 +152,7 @@ L is passed is as the first parameter. The return value is undefined. -I In the near future the return value of this method will be signifigant +I In the near future the return value of this method will be significant and there will be a means of passing additional parameters. =back Patch enclosed too. Bob Index: configuration.pod === --- configuration.pod (revision 19512) +++ configuration.pod (working copy) @@ -71,7 +71,7 @@ Templates for to be generated files usually have the extension '.in'. There is variable substitutes and funny macros like 'CONDITIONED_LINE' and -INVERSE_CONDITIONED_LINE'. +'INVERSE_CONDITIONED_LINE'. =head2 Prompt or Probe? @@ -152,7 +152,7 @@ L is passed is as the first parameter. The return value is undefined. -I In the near future the return value of this method will be signifigant +I In the near future the return value of this method will be significant and there will be a means of passing additional parameters. =back
[perl #43462] [PATCH] some clearups, illegal memory accessing
# New Ticket Created by Bram Geron # Please include the string: [perl #43462] # in the subject line of all future correspondence about this issue. # http://rt.perl.org/rt3/Ticket/Display.html?id=43462 > Firstly, there are some clearups in , I think they're self-explanatory. Secondly, I discovered that when you're using -D80, Parrot_free_context prints out the name of the 'sub' that the context was made for. I think we can't rely on the sub being there, as this example will show: - Create closure A over main. - Invoke closure A, creating context B. - Create closure C over closure A, storing a ref to context B (but not to closure A). Store it in a global var maybe. - Exit closure A. There is one less reference to context B. - Empty the global var holding closure C. - Free closure C. Now context B can be freed too: [free ctx 0x12345678 of sub ''] I got a segfault for it, but my test case is too large to attach and I think it will be hard to get the size down. It isn't very legible anyway. To solve this we can omit printing the sub name in Parrot_free_context. A patch that does this is in . Using -D80 does become less legible, but I think we prefer more correct behavior. Thanks, -- Bram Geron | GPG 0xE7B9E65E commit 75f9702c205694f1a81a00d0cc0181ae04436c0d Author: Bram Geron <[EMAIL PROTECTED]> Date: Thu Jun 28 17:23:46 2007 +0200 some clearups diff --git a/src/pmc/closure.pmc b/src/pmc/closure.pmc index 40073ad..fac291a 100644 --- a/src/pmc/closure.pmc +++ b/src/pmc/closure.pmc @@ -203,7 +203,7 @@ Destroys the closure. This is necessary in order to reclaim the context. struct Parrot_sub * sub = PMC_sub(SELF); #if CTX_LEAK_DEBUG if (Interp_debug_TEST(INTERP, PARROT_CTX_DESTROY_DEBUG_FLAG)) { -fprintf(stderr, "[destroy closure %p, context %p, refs=%d]\n", +fprintf(stderr, "[destroy closure %p, context %p with %d refs]\n", (void *)SELF, (void *)sub->outer_ctx, (sub->outer_ctx ? sub->outer_ctx->ref_count : 0)); } diff --git a/src/pmc/sub.pmc b/src/pmc/sub.pmc index 58d4ca1..abc94f7 100644 --- a/src/pmc/sub.pmc +++ b/src/pmc/sub.pmc @@ -58,10 +58,10 @@ Initializes the subroutine. *as some other sub has :outer(this) * - private2 ... tailcall invoked this Sub * - private3 ... pythonic coroutine generator flag - * - private4 ... :main (nee @MAIN) - * - private5 ... :load (nee @LOAD) - * - private6 ... :immediate (nee @IMMEDIATE) - * - private7 ... :postcomp (nee @POSTCOMP) + * - private4 ... :main (see @MAIN) + * - private5 ... :load (see @LOAD) + * - private6 ... :immediate (see @IMMEDIATE) + * - private7 ... :postcomp (see @POSTCOMP) * * see also the enum in include/parrot/sub.h * diff --git a/src/gc/register.c b/src/gc/register.c index b0e2a88..e71e745 100644 --- a/src/gc/register.c +++ b/src/gc/register.c @@ -472,13 +472,7 @@ Parrot_free_context(Interp *interp /*NN*/, struct Parrot_Context *ctxp /*NN*/, i if ( Interp_debug_TEST(interp, PARROT_CTX_DESTROY_DEBUG_FLAG) && ctxp->current_sub) { /* can't probably PIO_eprintf here */ -const Parrot_sub * const doomed = PMC_sub(ctxp->current_sub); - -fprintf(stderr, "[free ctx %p of sub '%s']\n", -(void *)ctxp, -(doomed->name == (void*)0xdeadbeef - ? "???" - : (char*)doomed->name->strstart)); +fprintf(stderr, "[free ctx %p]\n", (void *)ctxp); } #endif ptr = ctxp; diff --git a/src/pmc/sub.pmc b/src/pmc/sub.pmc index d57289d..58d4ca1 100644 --- a/src/pmc/sub.pmc +++ b/src/pmc/sub.pmc @@ -101,6 +101,9 @@ Destroys the subroutine. n && n->strstart ? (char*)n->strstart : "???"); } #endif +#ifndef NDEBUG +sub->name = NULL; /* detect it more often when we illegally try to print sub->name, like when using -D80 */ +#endif mem_sys_free(sub); PMC_struct_val(SELF) = NULL; }
Re: A problem about IPC::Open2
unsubscribe
[perl #43452] [PATCH] typo in docs/compiler_faq.pod
# New Ticket Created by Bob Wilkinson # Please include the string: [perl #43452] # in the subject line of all future correspondence about this issue. # http://rt.perl.org/rt3/Ticket/Display.html?id=43452 > Hello A typo in docs/compiler_faq.pod. [EMAIL PROTECTED]:~/src/parrot/docs$ svn diff Index: compiler_faq.pod === --- compiler_faq.pod(revision 19512) +++ compiler_faq.pod(working copy) @@ -395,7 +395,7 @@ =head2 How do I instantiate a class? -You can either do so with an interger type id: +You can either do so with an integer type id: $I0 = find_type 'Dog' new $P0, $I0# creates a Dog object and stores it in register $P0 Patch enclosed, too. Bob Index: compiler_faq.pod === --- compiler_faq.pod(revision 19512) +++ compiler_faq.pod(working copy) @@ -395,7 +395,7 @@ =head2 How do I instantiate a class? -You can either do so with an interger type id: +You can either do so with an integer type id: $I0 = find_type 'Dog' new $P0, $I0# creates a Dog object and stores it in register $P0
[perl #43462] [PATCH] some clearups, illegal memory accessing
From: Bram Geron (via RT) <[EMAIL PROTECTED]> Date: Sun, 01 Jul 2007 03:53:50 -0700 # New Ticket Created by Bram Geron # Please include the string: [perl #43462] # in the subject line of all future correspondence about this issue. # http://rt.perl.org/rt3/Ticket/Display.html?id=43462 > Firstly, there are some clearups in , I think they're self-explanatory. Thank you; applied as r19529. Secondly, I discovered that when you're using -D80, Parrot_free_context prints out the name of the 'sub' that the context was made for . . . I got a segfault for it, but my test case is too large to attach and I think it will be hard to get the size down. It isn't very legible anyway. You should never be able to make PIR segfault; I will look into this. If you wouldn't mind sending your test case, that might save me some trouble. To solve this we can omit printing the sub name in Parrot_free_context. A patch that does this is in . Using -D80 does become less legible, but I think we prefer more correct behavior. Thanks, -- Bram Geron | GPG 0xE7B9E65E It is really useful to print the sub name, especially when there are lots of contexts flying around. (For the record, I'm the one who changed it to do so.) The 0xdeadbeef test was trying to work around subs that were prematurely garbage-collected; I will try to fix this first. -- Bob Rogers http://rgrjr.dyndns.org/
Re: [svn:parrot] r19530 - in trunk/lib/Parrot: . Test
On Sunday 01 July 2007 15:35:57 [EMAIL PROTECTED] wrote: > [lib] Removed conditional declaration problems so that code conforms to > perl coding standards I'm not convinced this is right. (I've long thought that this policy was broken with regard to local declarations, which completely fails to exhibit the pseudo-static behavior that my declarations do. That pseudo-static behavior is precisely the reason this policy exists!) > Modified: trunk/lib/Parrot/Test.pm > === >=== --- trunk/lib/Parrot/Test.pm (original) > +++ trunk/lib/Parrot/Test.pm Sun Jul 1 15:35:56 2007 > @@ -293,16 +293,21 @@ > $err = "&STDOUT"; > } > > -local *OLDOUT if $out; > -local *OLDERR if $err; > +if ( $out ) { > + local *OLDOUT; > + # Save the old filehandles; we must not let them get closed. > + open OLDOUT, '>&STDOUT' or die "Can't save stdout"; ## no > critic InputOutput::ProhibitBarewordFileHandles + open STDOUT, '>', > $out or die "Can't redirect stdout to $out"; +} Outside of this block, *OLDOUT retains its previous value. I'm not sure how you get *STDOUT's original value back with this revision. > +if ( $err ) { > + local *OLDERR; > + # Save the old filehandles; we must not let them get closed. > + open OLDERR, '>&STDERR' or die "Can't save stderr"; ## no > critic InputOutput::ProhibitBarewordFileHandles > > -# Save the old filehandles; we must not let them get closed. > -open OLDOUT, '>&STDOUT' or die "Can't save stdout" if $out; ## no > critic InputOutput::ProhibitBarewordFileHandles That declaration's awfully ugly, but if it's impossible to make the policy actually check what it should be checking, I prefer it to the local-and-dup-in-a-block, unless someone can demonstrate that the blocks don't do the wrong thing. -- c
[perl #43462] [PATCH] some clearups, illegal memory accessing
From: Bram Geron (via RT) <[EMAIL PROTECTED]> Date: Sun, 01 Jul 2007 03:53:50 -0700 # New Ticket Created by Bram Geron # Please include the string: [perl #43462] # in the subject line of all future correspondence about this issue. # http://rt.perl.org/rt3/Ticket/Display.html?id=43462 > . . . Secondly, I discovered that when you're using -D80, Parrot_free_context prints out the name of the 'sub' that the context was made for. I think we can't rely on the sub being there, as this example will show: - Create closure A over main. - Invoke closure A, creating context B. - Create closure C over closure A, storing a ref to context B (but not to closure A). Store it in a global var maybe. - Exit closure A. There is one less reference to context B. - Empty the global var holding closure C. - Free closure C. Now context B can be freed too: [free ctx 0x12345678 of sub ''] I got a segfault for it, but my test case is too large to attach and I think it will be hard to get the size down. It isn't very legible anyway. I think you will have to send me your test case, or at least a more detailed recipe. I do not see how the above sequence of events can lead to a dangling reference to a deleted sub -- unless there is also a GC bug, in which case I am unlikely to be able to reproduce the problem from just a description. If this is really a GC problem, then you may be able to get your test case smaller by inserting "sweep 1" shortly before the point that it fails. HTH, -- Bob
Re: A problem about IPC::Open2
Admittedly, that wasn't particularly germane to the perl6 mailing list; but it did bring up an issue that's been bothering me for a while. I would like to see Perl6 handle the equivalent of IPC::Open2 using the same sort of syntax and semantics that it uses for sockets, by default. That is, I'd like to be able to say something like: $fh = "filename".open :rw; # same as open2 "filename", $in, $out; $line = =$fh; # same as $line = =$in; $fh.say "rewrite!"; # same as $out.say "rewrite!"; -- Jonathan "Dataweaver" Lang
[perl #43453] [PATCH] typos in docs/configuration.pod
Applied, along with some other small POD grammatical corrections, in r19532.
[perl #43452] [PATCH] typo in docs/compiler_faq.pod
Applied with one small change in r19533.
Re: [svn:parrot] r19533 - trunk/docs
On Jul 1, 2007, at 8:53 PM, [EMAIL PROTECTED] wrote: -You can either do so with an interger type id: +You can do so either with an integer type id: While we're going down the cleanup road, I'd really like to see ID spelled "ID", not "id". As a variable name, id is fine. In English text, it's not. -- Andy Lester => [EMAIL PROTECTED] => www.petdance.com => AIM:petdance