Coroutines in Perl 6 (Was: Re: Converting a Perl 5 "pseudo-continuation" to Perl 6)

2009-01-02 Thread Daniel Ruoso
Em Qui, 2009-01-01 às 12:34 -0800, Geoffrey Broadwell escreveu:
> In the below Perl 5 code, I refactored to pull the two halves of the PID
> file handling out of init_server(), but to do so, I had to return a sub
> from pid_file_handler() that acted as a "continuation".  The syntax is a
> bit ugly, though.  Is there a cleaner way to this in Perl 6?

Well,

If the STD Perl 6 doesn't support that, you can always declare a
sub-grammar that implements a 

  token routine_def: {...}

then you have something in the lines of:

  coro pid_file_handler {
  ... # first half
  yeld $something;
  ... # second half
  }

It's even easy to implement how it should work. Basically, yeld throws a
resumable control exception, the implicit "CONTROL" block of the routine
will then contain the code to handle that exception by aliasing the coro
in that state in the caller lexical scope, overriding the current
definition. And once the routine is called again, and returns or leaves,
you simply re-binds to the original routine. 

The above solution assumes a coro state is only available in the same
lexical scope as the first call, which may be a good idea to avoid
action-at-a-distance.

But maybe we even convince larry to push that into STD... since it's
such a nice feature...

daniel



Re: Coroutines in Perl 6 (Was: Re: Converting a Perl 5 "pseudo-continuation" to Perl 6)

2009-01-02 Thread Daniel Ruoso
Em Sex, 2009-01-02 às 08:34 -0300, Daniel Ruoso escreveu:
>   token routine_def: {...}

Actually, I was just looking at STD, and the correct token would be

  token routine_declarator:coro {   }

I was also looking at the spec files, and I realized that DRAFT S17
mentions coroutines, but its definition is a bit different then the one
I suggested, and the example poses a good reason:

  coro dbl { yield $_ * 2; yield $_; };
  (1..4).map:{ dbl($_) }
  # should result in 2 2 6 4

This example suggests that it will not install an alias in the caller
scope, but the code object itself stores its state.

The other difference is that falling out of a coro makes it restart
immediatly without returning any value (this one is a bit weird, I'd
expect it to return the last statement on the routine as well).

But one way or another yield (yes, I wrote it wrong in the previous
post) is still implemented as a control exception that is caught by the
implicit CONTROL block of the coro.

daniel



Re: Converting a Perl 5 "pseudo-continuation" to Perl 6

2009-01-02 Thread Leon Timmermans
When going OO, I'd say an augment()/inner() approach would be
cleanest. See 
http://search.cpan.org/~drolsky/Moose/lib/Moose/Cookbook/Basics/Recipe6.pod
for an example. I don't know how to express that in Perl 6 though.

Regards,

Leon

On Fri, Jan 2, 2009 at 2:08 AM, Steve Lukas  wrote:
> Hello,
> I'd vote for the OO-style.
> My reason is that the major criteria should be the reader perspective.
> It should be as clear as possible what's going on in the main code
> even if the reader doesn't know the hottest p6 tricks!
> What you are doing here is: two operations on the same thing (the pidfile).
> So the code should point out that it works twice on the same thing.
>
> I think it's best to have an object to show this
> whereas returning the sub/closure feels a bit confusing.
> Your right, this style is busy work, but it's not pointless.
>
> I would suggest a locally visible class to bring out the
> local, one time usage of that class. Btw. what is the best way to do so?
>
> Kind regards
> Stefan
>
>
> --- On Thu, 1/1/09, Geoffrey Broadwell  wrote:
> From: Geoffrey Broadwell 
> Subject: Converting a Perl 5 "pseudo-continuation" to Perl 6
> To: perl6-us...@perl.org, perl6-langu...@perl.org
> Date: Thursday, January 1, 2009, 3:34 PM
>
> In the below Perl 5 code, I refactored to pull the two halves of the PID
> file handling out of init_server(), but to do so, I had to return a sub
> from pid_file_handler() that acted as a "continuation".  The syntax
> is a
> bit ugly, though.  Is there a cleaner way to this in Perl 6?
>
> ##
> sub init_server {
>my %options  = @_;
>
># ...
>
># Do top (pre-daemonize) portion of PID file handling.
>my $handler = pid_file_handler($options{pid_file});
>
># Detach from parent session and get to clean state.
>become_daemon();
>
># Do bottom (post-daemonize) portion of PID file handling.
>$handler->();
>
># ...
> }
>
> sub pid_file_handler {
># Do top half (pre-daemonize) PID file handling ...
>my $filename = shift;
>my $basename = lc $BRAND;
>my $PID_FILE = $filename || "$PID_FILE_DIR/$basename.pid";
>my $pid_file = open_pid_file($PID_FILE);
>
># ... and return a "continuation" on the bottom half
> (post-daemonize).
>return sub {
>$MASTER_PID  =  $$;
>print $pid_file $$;
>close $pid_file;
>};
> }
> ##
>
> When I asked this question on #perl6, pmurias suggested using
> gather/take syntax, but that didn't feel right to me either -- it's
> contrived in a similar way to using a one-off closure.
>
> pmichaud offered several possibilities (I've converted some of his
> suggestions expressed as prose into code, so the errors there are mine):
>
> 1. Take advantage of Perl 6 syntax reduction to turn 'return sub {...}'
>   into 'return {...}' (or even just fall of the end with
> '{...}', I
>   suppose).  This is visually slightly better, but still leaves the
>   bottom half inside a block that merely exists to satisfy Perl, not
>   actually representing anything intrinsic about the problem.
>
> 2. Throw a resumable exception in the middle:
>
>   sub init_server {
>   # ...
>   pid_file_handler($options{pid_file});
>   become_daemon();
>   pid_file_handler();
>   # ...
>   }
>
>   sub pid_file_handler {
>   # ... top half ...
>   throw ResumableException;
>   # ... bottom half ...
>   }
>
>   He also suggested a variant syntax with an adverb on return:
>
>   sub pid_file_handler {
>   # ... top half ...
>   return :resumable;
>   # ... bottom half ...
>   }
>
>   I suggested a naked yield syntax:
>
>   sub pid_file_handler {
>   # ... top half ...
>   yield;
>   # ... bottom half ...
>   }
>
>   These all desugar to the same thing, of course.
>
> 3. Make become_daemon a part of pid_file_handler, or vice-versa.
>   I rejected both of these on the basis of separating different
>   things into different subs.  The two tasks are only tangentially
>   related, and neither really seems like a subordinate op of the
>   other.
>
> 4. In order to keep the sub separate, but still not split the
>   pid_file_handler call, I came up with a variation of #3 in which
>   pid_file_handler takes a callback parameter:
>
>   sub init_server {
>   # ...
>   pid_file_handler($options{pid_file}, &become_daemon);
>   # ...
>   }
>
>   sub pid_file_handler($pid_file, &callback) {
>   # ... top half ...
>   callback();
>   # ... bottom half ...
>   }
>
>   That seems like a silly contortion to hide the problem, and
>   doesn't represent my intent well -- the pid file handler doesn't
>   need to send a message, it needs to yield control while waiting
>   for something else to happen.
>
> 5. Make a new PidHandler class and address the problem in OO fashion:
>
>   sub init_server {
>   # ...
>   my $pid_handler = PidHandler.new(file => $options{pid_file});
>   $pid_handler.top();
>   become_daemon();
>   $pid_handler.bottom(

r24732 - docs/Perl6/Spec

2009-01-02 Thread pugs-commits
Author: particle
Date: 2009-01-02 14:36:54 +0100 (Fri, 02 Jan 2009)
New Revision: 24732

Modified:
   docs/Perl6/Spec/S06-routines.pod
   docs/Perl6/Spec/S19-commandline.pod
Log:
[spec] get rid of ugly and confusing C<+option> syntax (bad unix memes)--

Modified: docs/Perl6/Spec/S06-routines.pod
===
--- docs/Perl6/Spec/S06-routines.pod2009-01-01 22:27:50 UTC (rev 24731)
+++ docs/Perl6/Spec/S06-routines.pod2009-01-02 13:36:54 UTC (rev 24732)
@@ -2735,15 +2735,17 @@
 Common Unix command-line conventions are mapped onto the capture
 as follows:
 
-Assuming C<-n> is the shortname for C<--name>,
+Assuming C<-n> is the short name for C<--name>,
 On command line... $*ARGS capture gets...
 
+# Short names
 -n :name
 -n=value   :name
 -n="spacy value"   :name«'spacy value'»
 -n='spacy value'   :name«'spacy value'»
 -n=val1,'val 2',etc:name«val1 'val 2' etc»
 
+# Long names
 --name :name# only if declared Bool
 --name=value   :name # don't care
 --name value   :name # only if not declared Bool
@@ -2756,15 +2758,16 @@
 --name val1 'val 2' etc:name«val1 'val 2' etc» # only if declared @
 -- # end named argument processing
 
-+name  :!name
-+name=value:name but False
-+name="spacy value":name«'spacy value'» but False
-+name='spacy value':name«'spacy value'» but False
-+name=val1,'val 2',etc :name«val1 'val 2' etc» but False
+# Negation
+--/name:!name
+--/name=value  :name but False
+--/name="spacy value"  :name«'spacy value'» but False
+--/name='spacy value'  :name«'spacy value'» but False
+--/name=val1,'val 2',etc   :name«val1 'val 2' etc» but False
 
+# Native
 :name  :name
-:!name :!name   # potential conflict with ! histchar
-:/name :!name   # potential workaround?
+:/name :!name
 :name=value:name
 :name="spacy value":name«'spacy value'»
 :name='spacy value':name«'spacy value'»

Modified: docs/Perl6/Spec/S19-commandline.pod
===
--- docs/Perl6/Spec/S19-commandline.pod 2009-01-01 22:27:50 UTC (rev 24731)
+++ docs/Perl6/Spec/S19-commandline.pod 2009-01-02 13:36:54 UTC (rev 24732)
@@ -29,7 +29,7 @@
 
 =item *
 
-A much smarter default command-line processor in the core
+A smart default command-line processor in the core
 
 =item *
 
@@ -111,7 +111,7 @@
 
 =item *
 
-Options must begin with one of the following symbols: C<< < -- - + : > >>.
+Options must begin with one of the following symbols: C<< < -- - : > >>.
 
 =item *
 
@@ -120,7 +120,7 @@
 =item *
 
 All options have a multi-character, descriptive name for increased clarity.
-Multi-character option names always begin with C<-->, C<+>, or C<:>.
+Multi-character option names always begin with C<--> or C<:>.
 
 =item *
 
@@ -138,16 +138,8 @@
 
 =item *
 
-Options may be negated with C or C, for example C<:/name>
+Options may be negated with C, for example C<--/name>, C<:/name>, C<-/n>.
 
-[:/name reminds me more of an end tag than a negated, but I see
-why you want it, given the history of history characters...interestingly,
-:0name has the same effect in current p6, since we generalized :3x
-and such.]
-
-{{ dunno how TIMTOWTDI i want to get here, so i haven't changed the text
-above, but have standardized on C below. }}
-
 =item *
 
 The special option C<--> signals the parser to stop option processing.
@@ -239,8 +231,8 @@
   token option {
   [
 [
-  $=[ '--' | '-' | '+' | ':' ]
-  $=[ '!' | '/' ]?
+  $=[ '--' | '-' | ':' ]
+  $=[ '/' ]?
   
 ]
 [ '='  [ ','  ]* ]?



Re: r24711 - docs/Perl6/Spec

2009-01-02 Thread jerry gay
On Thu, Jan 1, 2009 at 03:30, Darren Duncan  wrote:
> pugs-comm...@feather.perl6.nl wrote:
>>
>> --name  :name
>> --name=value:name
>> --name="spacy value":name«'spacy value'»
>> --name='spacy value':name«'spacy value'»
>> --name=val1,'val 2',etc :name«val1 'val 2' etc»
>> +-n :name
>> +-n=value   :name
>> +-n="spacy value"   :name«'spacy value'»
>> +-n='spacy value'   :name«'spacy value'»
>> +-n=val1,'val 2',etc:name«val1 'val 2' etc»
>>   --name :name# only if declared Bool
>> --name=value   :name # don't care
>
> Is that right?  Should the right column example not also be shortened to :n
> ?  I thought the single-dash names only allowed a single character in a name
> on purpose, since multiple chars after a - were multiple options. -- Darren
> Duncan
>
yes, it's right. options have both long and short names.
perhaps you missed the change to the paragraph above:

+Assuming C<-n> is the shortname for C<--name>,

that reads "short name" (two words) as of r24732.

if you want to set C to C, use C<--n=value>.
~jerry


r24734 - docs/Perl6/Spec

2009-01-02 Thread pugs-commits
Author: particle
Date: 2009-01-02 15:15:35 +0100 (Fri, 02 Jan 2009)
New Revision: 24734

Modified:
   docs/Perl6/Spec/S06-routines.pod
   docs/Perl6/Spec/S19-commandline.pod
Log:
[spec] options must appear before script name; update version/date metadata

Modified: docs/Perl6/Spec/S06-routines.pod
===
--- docs/Perl6/Spec/S06-routines.pod2009-01-02 13:46:16 UTC (rev 24733)
+++ docs/Perl6/Spec/S06-routines.pod2009-01-02 14:15:35 UTC (rev 24734)
@@ -13,9 +13,9 @@
 
   Maintainer: Larry Wall 
   Date: 21 Mar 2003
-  Last Modified: 27 Dec 2008
+  Last Modified: 2 Jan 2009
   Number: 6
-  Version: 98
+  Version: 99
 
 
 This document summarizes Apocalypse 6, which covers subroutines and the

Modified: docs/Perl6/Spec/S19-commandline.pod
===
--- docs/Perl6/Spec/S19-commandline.pod 2009-01-02 13:46:16 UTC (rev 24733)
+++ docs/Perl6/Spec/S19-commandline.pod 2009-01-02 14:15:35 UTC (rev 24734)
@@ -14,8 +14,8 @@
 
   Maintainer: Jerry Gay 
   Date: 12 Dec 2008
-  Last Modified: 31 Dec 2008
-  Version: 6
+  Last Modified: 2 Jan 2009
+  Version: 7
 
 This is a draft document. This document describes the command line interface.
 It has changed extensively from previous versions of Perl in order to increase
@@ -70,21 +70,12 @@
 line, but it is made available at run-time in the read-only C<$?PROGRAM>
 variable.
 
-Command line I are further broken down into I and
-I. Unlike Perl 5, I and I may be intermixed on the
-command line. This mirrors the Perl 6 argument syntax for Routines, which
-allows named and positional parameters to be intermixed. The recommendation
-for parameter ordering applies here as well, with a slight twist: keep all
-command line options together, even though this is not enforced, in order to
-avoid confusion.
+Command line I are broken down into I and I.
+Each option may take zero or more values. After all options have been
+processed, the remaining values (if any) generally consist of the name of a
+script, followed by arguments for that script.
 
-[ This policy may be counter-intuitive to current comand-line cultures. ]
 
-{{ 'ack' is a notable exception to the old rule, and i like the freedom.
-besides, perl 6 is about looking forward, and creating a new culture. :)
-on the other hand, i won't fight to keep this if it doesn't get support. }}
-
-
 =head1 Backward (In)compatibility
 
 Muscles have a long memory. You may find yourself typing your favorite Perl 5



r24735 - docs/Perl6/Spec

2009-01-02 Thread pugs-commits
Author: particle
Date: 2009-01-02 16:42:53 +0100 (Fri, 02 Jan 2009)
New Revision: 24735

Modified:
   docs/Perl6/Spec/S19-commandline.pod
Log:
[S19] explain how script passed on command-line or via STDIN works

Modified: docs/Perl6/Spec/S19-commandline.pod
===
--- docs/Perl6/Spec/S19-commandline.pod 2009-01-02 14:15:35 UTC (rev 24734)
+++ docs/Perl6/Spec/S19-commandline.pod 2009-01-02 15:42:53 UTC (rev 24735)
@@ -73,7 +73,9 @@
 Command line I are broken down into I and I.
 Each option may take zero or more values. After all options have been
 processed, the remaining values (if any) generally consist of the name of a
-script, followed by arguments for that script.
+script for Perl to execute, followed by arguments for that script. If no
+values remain, Perl 6 reads the script from STDIN--you must specify the
+special C<-> option if you wish to pass arguments to a script read from STDIN.
 
 
 =head1 Backward (In)compatibility
@@ -305,9 +307,10 @@
 
 {{rename done}}
 
+
 =head1 Option Reference
 
-Perl 6 options, descriptions, categories, and services
+Perl 6 options, descriptions, and services.
 
 =over 4
 
@@ -458,15 +461,12 @@
 
 Notes: Desugars to C<++PARSER --prelude=Perl6-autoloop-print ++/PARSER>.
 
-=item --search-path, -S
+=item --search-path, -S path
 
-Use path to search for program.
+Use path to search for script specified on command-line.
 
 Service: Runtime
 
-[you need a story for when the first argument is treated as
-the program name. e.g. when you *don't* use -e to supply the program.]
-
 =item --taint, -T
 
 Turns on "taint" checking. See L<...> for details.



Re: Converting a Perl 5 "pseudo-continuation" to Perl 6

2009-01-02 Thread Geoffrey Broadwell
On Fri, 2009-01-02 at 14:19 +0200, Leon Timmermans wrote:
> When going OO, I'd say an augment()/inner() approach would be
> cleanest. See 
> http://search.cpan.org/~drolsky/Moose/lib/Moose/Cookbook/Basics/Recipe6.pod
> for an example. I don't know how to express that in Perl 6 though.

There's no description on that page, just sample code, but it looks like
augment performs a similar function to the .wrap method on Routines in
Perl 6.  That's an interesting variation of my approach #4, I think:

> > 4. In order to keep the sub separate, but still not split the
> >   pid_file_handler call, I came up with a variation of #3 in which
> >   pid_file_handler takes a callback parameter:
> >
> >   sub init_server {
> >   # ...
> >   pid_file_handler($options{pid_file}, &become_daemon);
> >   # ...
> >   }
> >
> >   sub pid_file_handler($pid_file, &callback) {
> >   # ... top half ...
> >   callback();
> >   # ... bottom half ...
> >   }

I like your idea a little better than the callback method, because I can
see the logic behind saying I want to make an enhanced version of
become_daemon that is *also* able to handle PID files.  However, it ties
the two together -- the PID file handling cannot be used in any context
other than becoming a daemon, and in particular it's not obvious how you
would unit test it.


-'f




r24737 - docs/Perl6/Spec

2009-01-02 Thread pugs-commits
Author: particle
Date: 2009-01-02 17:08:51 +0100 (Fri, 02 Jan 2009)
New Revision: 24737

Modified:
   docs/Perl6/Spec/S19-commandline.pod
Log:
[spec] add signature for perl6, and make --output-format entirely 
implementation-specific

Modified: docs/Perl6/Spec/S19-commandline.pod
===
--- docs/Perl6/Spec/S19-commandline.pod 2009-01-02 15:50:03 UTC (rev 24736)
+++ docs/Perl6/Spec/S19-commandline.pod 2009-01-02 16:08:51 UTC (rev 24737)
@@ -312,6 +312,30 @@
 
 Perl 6 options, descriptions, and services.
 
+=head2 Synopsis
+
+  multi sub perl6(
+Bool :a($autosplit),
+Bool :c($check-syntax),
+Bool :$doc,
+:e($execute),
+:$execute-lax,  #TODO fix illegal -e6 syntax. -6? not legal. -x? hrmm
+Bool :F($autoloop-split),
+Bool :h($help),
+:I(@include),
+#TODO -M,
+Bool :n($autoloop-no-print),
+:O($output-format) = 'exe',
+:o($output-file) = $*OUT,
+Bool :p($autoloop-print),
+:S(@search-path),
+Bool :T($taint),
+Bool :v($version),
+Bool :V($verbose-config),
+  );
+
+=head2 Reference
+
 =over 4
 
 =item --autosplit, -a
@@ -441,12 +465,11 @@
 
 Notes: Desugars to C<++PARSER --prelude=Perl6-autoloop-no-print ++/PARSER>.
 
-=item --output-format, -O [format]
+=item --output-format, -O format
 
 Specify the file format for the output file requested with C<--output-file>.
-Defaults to 'exe', which represents the target platform's idea of an
-executable. Other valid values are implementation-specific, so consult the
-documentation for your compiler toolchain.
+This option is implementation-specific, so consult the documentation for your
+Perl 6 implementation.
 
 =item --output-file, -o [filename]
 



r24738 - docs/Perl6/Spec

2009-01-02 Thread pugs-commits
Author: particle
Date: 2009-01-02 17:17:06 +0100 (Fri, 02 Jan 2009)
New Revision: 24738

Modified:
   docs/Perl6/Spec/S19-commandline.pod
Log:
[spec] add note about dangers of mixing -e and -e6

Modified: docs/Perl6/Spec/S19-commandline.pod
===
--- docs/Perl6/Spec/S19-commandline.pod 2009-01-02 16:08:51 UTC (rev 24737)
+++ docs/Perl6/Spec/S19-commandline.pod 2009-01-02 16:17:06 UTC (rev 24738)
@@ -647,6 +647,9 @@
 env var? maybe -E
 
 [could be posed in terms of substituting a different prelude]
+
+mixing -e and -e6 can lead to problems, for example:
+  perl -e "my $x = 1;" -e "print $x" -e6 "if $x"
 }}
 
 =for vim:set expandtab sw=4:



Re: r24737 - docs/Perl6/Spec

2009-01-02 Thread Geoffrey Broadwell
On Fri, 2009-01-02 at 17:08 +0100, pugs-comm...@feather.perl6.nl wrote:
> +=head2 Synopsis
> +
> +  multi sub perl6(
> +Bool :a($autosplit),
> +Bool :c($check-syntax),
> +Bool :$doc,
> +:e($execute),
> +:$execute-lax,  #TODO fix illegal -e6 syntax. -6? not legal. -x? hrmm
> +Bool :F($autoloop-split),
> +Bool :h($help),
> +:I(@include),
> +#TODO -M,
> +Bool :n($autoloop-no-print),
> +:O($output-format) = 'exe',
> +:o($output-file) = $*OUT,
> +Bool :p($autoloop-print),
> +:S(@search-path),
> +Bool :T($taint),
> +Bool :v($version),
> +Bool :V($verbose-config),
> +  );

I find this a little difficult to skim, because parallel things are not
aligned.  Aligning on ':' should make things much easier on the eyes:

multi sub perl6(
Bool :a($autosplit),
Bool :c($check-syntax),
Bool :$doc,
 :e($execute),
 :$execute-lax,
Bool :F($autoloop-split),
Bool :h($help),
 :I(@include),
 #TODO -M,
Bool :n($autoloop-no-print),
 :O($output-format) = 'exe',
 :o($output-file)   = $*OUT,
Bool :p($autoloop-print),
 :S(@search-path),
Bool :T($taint),
Bool :v($version),
Bool :V($verbose-config),
);

Ah, that's a bit better.  Looking at the above, is $execute-lax supposed
to be a boolean, or is it really a generic scalar?  It's also not
obvious what a boolean named $doc does -- which probably means either
that it's not supposed to be a boolean, or it needs a somewhat more
descriptive long name (or both).

Also, in Perl 5 taint is tri-valued, because it has a warnings-only
mode.  How will that be supported by Perl 6?

Finally, how do the defaults of $output-file and $output-format interact
so that the default behavior remains compile-and-execute?  Changing the
default to compile-to-exe seems unperlish to me 


-'f




r24739 - docs/Perl6/Spec

2009-01-02 Thread pugs-commits
Author: particle
Date: 2009-01-02 19:31:51 +0100 (Fri, 02 Jan 2009)
New Revision: 24739

Modified:
   docs/Perl6/Spec/S19-commandline.pod
Log:
[spec] C<-e6> isn't a separate item, it's a idiom meaning -e '6;'; format perl6 
signature, (geoff broadwell)++

Modified: docs/Perl6/Spec/S19-commandline.pod
===
--- docs/Perl6/Spec/S19-commandline.pod 2009-01-02 16:17:06 UTC (rev 24738)
+++ docs/Perl6/Spec/S19-commandline.pod 2009-01-02 18:31:51 UTC (rev 24739)
@@ -15,7 +15,7 @@
   Maintainer: Jerry Gay 
   Date: 12 Dec 2008
   Last Modified: 2 Jan 2009
-  Version: 7
+  Version: 8
 
 This is a draft document. This document describes the command line interface.
 It has changed extensively from previous versions of Perl in order to increase
@@ -318,17 +318,16 @@
 Bool :a($autosplit),
 Bool :c($check-syntax),
 Bool :$doc,
-:e($execute),
-:$execute-lax,  #TODO fix illegal -e6 syntax. -6? not legal. -x? hrmm
+ :e($execute),
 Bool :F($autoloop-split),
 Bool :h($help),
-:I(@include),
+ :I(@include),
 #TODO -M,
 Bool :n($autoloop-no-print),
-:O($output-format) = 'exe',
-:o($output-file) = $*OUT,
+ :O($output-format) = 'exe',
+ :o($output-file) = $*OUT,
 Bool :p($autoloop-print),
-:S(@search-path),
+ :S(@search-path),
 Bool :T($taint),
 Bool :v($version),
 Bool :V($verbose-config),
@@ -393,6 +392,10 @@
 Execute a single-line program. Multiple C<-e> options may be chained together,
 each one representing an input line with an implicit newline at the end.
 
+If you wish to run in lax mode, without strictures and warnings enabled,
+your first -e on the command line should be passed a value of '6', like C<-e6>.
+See L for details.
+
 Service: Runtime
 
 Notes: Returns a function that's executed unless otherwise modified by
@@ -404,13 +407,6 @@
 redirection of a vaguely here-docish flavor.  You could combine it
 with -c or --doc for instance, so not exclusive.]
 
-=item --execute-lax, -e6
-
-Execute in lax mode, without strictures and warnings enabled.
-See L for details.
-
-Service: Runtime
-
 =item --autoloop-split, -F [string, closure, etc]
 
 Pattern to split on (used with -a). Accepts unicode strings (as long as your



Re: r24737 - docs/Perl6/Spec

2009-01-02 Thread jerry gay
On Fri, Jan 2, 2009 at 09:27, Geoffrey Broadwell  wrote:
> On Fri, 2009-01-02 at 17:08 +0100, pugs-comm...@feather.perl6.nl wrote:
>> +=head2 Synopsis
>> +
>> +  multi sub perl6(
>> +Bool :a($autosplit),
>> +Bool :c($check-syntax),
>> +Bool :$doc,
>> +:e($execute),
>> +:$execute-lax,  #TODO fix illegal -e6 syntax. -6? not legal. -x? hrmm
>> +Bool :F($autoloop-split),
>> +Bool :h($help),
>> +:I(@include),
>> +#TODO -M,
>> +Bool :n($autoloop-no-print),
>> +:O($output-format) = 'exe',
>> +:o($output-file) = $*OUT,
>> +Bool :p($autoloop-print),
>> +:S(@search-path),
>> +Bool :T($taint),
>> +Bool :v($version),
>> +Bool :V($verbose-config),
>> +  );
>
> I find this a little difficult to skim, because parallel things are not
> aligned.  Aligning on ':' should make things much easier on the eyes:
>
> multi sub perl6(
>Bool :a($autosplit),
>Bool :c($check-syntax),
>Bool :$doc,
> :e($execute),
> :$execute-lax,
>Bool :F($autoloop-split),
>Bool :h($help),
> :I(@include),
> #TODO -M,
>Bool :n($autoloop-no-print),
> :O($output-format) = 'exe',
> :o($output-file)   = $*OUT,
>Bool :p($autoloop-print),
> :S(@search-path),
>Bool :T($taint),
>Bool :v($version),
>Bool :V($verbose-config),
> );
>
thanks, done.

> Ah, that's a bit better.  Looking at the above, is $execute-lax supposed
> to be a boolean, or is it really a generic scalar?  It's also not
> obvious what a boolean named $doc does -- which probably means either
> that it's not supposed to be a boolean, or it needs a somewhat more
> descriptive long name (or both).
>
--execute-lax is gone, since -e6 is just an idiomatic shortcut for
--execute '6', which is outlined in Synopsis 11.

> Also, in Perl 5 taint is tri-valued, because it has a warnings-only
> mode.  How will that be supported by Perl 6?
>
well, perl 5 uses two flags for this, and i'm as yet undecided what to
do about it.one argument is that i should keep the syntax from perl 5
consistent where possible. another argument is that taint warnings
mode is relatively unused (and for development only) so doesn't
deserve its own flag. maybe -t goes away, and -T takes a param that
defaults to C but can be set to something like
C.

> Finally, how do the defaults of $output-file and $output-format interact
> so that the default behavior remains compile-and-execute?  Changing the
> default to compile-to-exe seems unperlish to me 
>
i've gotten rid of default values for these options. they're strictly
implementation-dependent. the syntax exists to allow rakudo to emit
pbc files, and pugs to emit javascript, and i think is flexible enough
for other implementations. maybe i'll remove them entirely, since they
are implementation-dependent and can be done with ++metasyntax.

in any case, the default behavior of perl 6 is unchanged from perl 5,
which is compile-and-execute.

~jerry


Re: r24737 - docs/Perl6/Spec

2009-01-02 Thread Geoffrey Broadwell
Thank you for the quick turnaround!

On Fri, 2009-01-02 at 10:55 -0800, jerry gay wrote:
> On Fri, Jan 2, 2009 at 09:27, Geoffrey Broadwell  wrote:
> > It's also not
> > obvious what a boolean named $doc does -- which probably means either
> > that it's not supposed to be a boolean, or it needs a somewhat more
> > descriptive long name (or both).

I think this is the only remaining item you had not yet responded to --
er, unless I missed it.


-'f




Re: r24737 - docs/Perl6/Spec

2009-01-02 Thread jerry gay
On Fri, Jan 2, 2009 at 11:24, Geoffrey Broadwell  wrote:
> Thank you for the quick turnaround!
>
> On Fri, 2009-01-02 at 10:55 -0800, jerry gay wrote:
>> On Fri, Jan 2, 2009 at 09:27, Geoffrey Broadwell  wrote:
>> > It's also not
>> > obvious what a boolean named $doc does -- which probably means either
>> > that it's not supposed to be a boolean, or it needs a somewhat more
>> > descriptive long name (or both).
>
> I think this is the only remaining item you had not yet responded to --
> er, unless I missed it.
>
oh, yes, whoops! i responded to someone else in #pugs earlier, and
forgot to address the item here. C replaces p5's
C (that's the latest idea from damian, although it seems not
to be published yet).

the most likely short names, C<< < -d -o -c > >> are all taken by
either p5 or p6 command-line. i don't want to use C<-d>, because that
has to do with the debugger in p5, so makes it harder for p6 to catch
accidental usage. C<--doc> probably warrants a short name, since it
will be called frequently--i hope, reducing irc traffic :) but i
haven't decided on a good name yet. i'm open to suggestions.

~jerry


Re: Converting a Perl 5 "pseudo-continuation" to Perl 6

2009-01-02 Thread Aristotle Pagaltzis
* Geoffrey Broadwell  [2009-01-01 21:40]:
> In the below Perl 5 code, I refactored to pull the two halves of the PID
> file handling out of init_server(), but to do so, I had to return a sub
> from pid_file_handler() that acted as a "continuation".  The syntax is a
> bit ugly, though.  Is there a cleaner way to this in Perl 6?
>
> ##
> sub init_server {
> my %options  = @_;
>
> # ...
>
> # Do top (pre-daemonize) portion of PID file handling.
> my $handler = pid_file_handler($options{pid_file});
>
> # Detach from parent session and get to clean state.
> become_daemon();
>
> # Do bottom (post-daemonize) portion of PID file handling.
> $handler->();
>
> # ...
> }
>
> sub pid_file_handler {
> # Do top half (pre-daemonize) PID file handling ...
> my $filename = shift;
> my $basename = lc $BRAND;
> my $PID_FILE = $filename || "$PID_FILE_DIR/$basename.pid";
> my $pid_file = open_pid_file($PID_FILE);
>
> # ... and return a "continuation" on the bottom half (post-daemonize).
> return sub {
> $MASTER_PID  =  $$;
> print $pid_file $$;
> close $pid_file;
> };
> }
> ##
>
> When I asked this question on #perl6, pmurias suggested using
> gather/take syntax, but that didn't feel right to me either --

> it's contrived in a similar way to using a one-off closure.

Contrived how? I always found implicit continuations distasteful
in the same way that `each` and the boolean flip-flop are bad in
Perl 5: because they tie program state to a location in the code.
When there is state, it should be passed around explicitly. So I
think the return-a-closure solution is actually ideal.

F.ex. it keeps you entirely clear of the troublesome question of
when a subsequent call should restart the sub from the beginning
or resume it – should that happen when identical arguments are
passed? Or when no arguments are passed? Are there any rules
about the proximity of the calls in the code? Or does the
coroutine state effectively become global state (like with `each`
and `pos` in Perl 5)?

When you have an explicit entity representing the continuation,
all of these questions resolve themselves in at once: all calls
to the original routine create a new continuation, and all calls
via the state object are resumptions. There is no ambiguity or
subtlety to think about.

So from the perspective of the caller, I consider the “one-off”
closure ideal: the first call yields an object that can be used
to resume the call.

However, I agree that having to use an extra block inside the
routine and return it explicity is suboptimal. It would be nice
if there was a `yield` keyword that not only threw a resumable
exception, but also closed over the exception object in a
function that, when called, resumes the original function.

That way, you get this combination:

sub pid_file_handler ( $filename ) {
# ... top half ...
yield;
# ... bottom half ...
}

sub init_server {
# ...
my $write_pid = pid_file_handler( $options );
become_daemon();
$write_pid();
# ...
}

Regards,
-- 
Aristotle Pagaltzis // 


[perl #61916] initialization parameters from base classes

2009-01-02 Thread Dave Whipp
# New Ticket Created by  "Dave Whipp" 
# Please include the string:  [perl #61916]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=61916 >


The default "new" method allows values of attributes to be set as
named args -- but rakudo doesn't hoist params from base classes:

rakudo: class A { has $.foo }; class B is A { has $.bar 
};
B.new( foo => 1, bar => 2)
rakudo 34834: OUTPUT«You passed an initialization 
parameter
that does not have a matching attribute.␤current instr.: 'die' pc
14812 (src/builtins/control.pir:204)␤»
pugs: class A { has $.foo }; class B is A { has $.bar };
B.new( foo => 1, bar => 2)
pugs: RESULT«B.new((\("bar", 2), \("foo", 1))»


[perl #61918] classes don't get a default .perl method

2009-01-02 Thread Dave Whipp
# New Ticket Created by  "Dave Whipp" 
# Please include the string:  [perl #61918]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=61918 >


rakudo: class A { has $.foo }; my A $a .=new( foo => 42 
); say $a.perl
rakudo 34835: OUTPUT«Method 'perl' not found for 
invocant of
class 'A'␤current instr.: '_block14' pc 158 (EVAL_13:73)␤»
pugs: class A { has $.foo }; my A $a .=new( foo => 42 
); say $a.perl
pugs: OUTPUT«\A.new((\("foo", 42),)␤»


[perl #61920] [PATCH] test division in 02-op-math.t

2009-01-02 Thread Kyle Hasselbacher
# New Ticket Created by  "Kyle Hasselbacher" 
# Please include the string:  [perl #61920]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=61920 >


I didn't see division in with the other "basic math ops", so...

Index: languages/perl6/t/00-parrot/02-op-math.t
===
--- languages/perl6/t/00-parrot/02-op-math.t(revision 34835)
+++ languages/perl6/t/00-parrot/02-op-math.t(working copy)
@@ -4,7 +4,7 @@

 use v6;

-say '1..14';
+say '1..15';

 print 'ok ';
 say 0 + 1;
@@ -42,3 +42,7 @@
 say -(-13);
 print 'ok ';
 say abs -14;
+
+# 15
+print 'ok ';
+say 30 / 2;


[perl #61924] Incrementing an untyped, undefined variable makes Rakudo dump core

2009-01-02 Thread via RT
# New Ticket Created by  Markus Laker 
# Please include the string:  [perl #61924]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=61924 >


Two things are unexpected here: the fact that Rakudo thinks $x is
an instance of class Timer, and the corrupted double-linked list.

Please let me know if there's more I can do to help characterise the
bug, or if I can report it in some more useful form.

Best regards,

Markus



m...@edward:~/perl/6$ ~/bin/perl6 -e 'my Any $x; ++$x; $x.say'
1
m...@edward:~/perl/6$ ~/bin/perl6 -e 'my $x = 0; ++$x; $x.say'
1
m...@edward:~/perl/6$ ~/bin/perl6 -e 'my $x; ++$x; $x.say'
increment() not implemented in class 'Timer'
current instr.: 'prefix:++' pc 17895 (src/builtins/op.pir:60)
called from Sub '_block14' pc 69 (EVAL_9:43)
called from Sub 'parrot;PCT;HLLCompiler;eval' pc 892 
(src/PCT/HLLCompiler.pir:508)
called from Sub 'parrot;PCT;HLLCompiler;command_line' pc 1436 
(src/PCT/HLLCompiler.pir:768)
called from Sub 'parrot;Perl6;Compiler;main' pc 19057 (perl6.pir:162)
*** glibc detected *** /home/msl/bin/perl6: corrupted double-linked list: 
0x08702000 ***
=== Backtrace: =
/lib/tls/i686/cmov/libc.so.6[0xb77e268e]
/lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb77e5e30]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(mem_sys_free+0x23)[0xb7b9d343]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7b9de3d]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bab23f]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_exit+0x70)[0xb7b933e0]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7b92d46]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_ex_throw_from_c+0x61)[0xb7b92db1]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7b92fb1]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7cf3e26]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_default_increment+0x23)[0xb7cf4a23]
[0xb7653801]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_inc_p+0x4b)[0xb7b3081b]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bdb535]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7badc09]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bae723]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bae95c]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_runops_fromc_args+0x43)[0xb7baf0b3]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_ex_throw_from_c+0x1cc)[0xb7b92f1c]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7b92fb1]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bceb1a]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7db0824]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_Class_init_pmc+0x21f)[0xb7db141f]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(pmc_new_init+0x107)[0xb7bda1b7]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_newclass_p_p+0x58)[0xb7b4c7f8]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bdb535]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7badc09]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bae723]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bae95c]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_runops_fromc_args+0x43)[0xb7baf0b3]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_ex_throw_from_c+0x1cc)[0xb7b92f1c]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7b92fb1]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bceb1a]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7db0824]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_Class_init_pmc+0x21f)[0xb7db141f]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(pmc_new_init+0x107)[0xb7bda1b7]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_newclass_p_p+0x58)[0xb7b4c7f8]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bdb535]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7badc09]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bae723]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bae95c]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_runops_fromc_args+0x43)[0xb7baf0b3]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_ex_throw_from_c+0x1cc)[0xb7b92f1c]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7b92fb1]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bceb1a]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7db0824]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_Class_init_pmc+0x21f)[0xb7db141f]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(pmc_new_init+0x107)[0xb7bda1b7]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_newclass_p_p+0x58)[0xb7b4c7f8]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bdb535]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7badc09]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bae723]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bae95c]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_runops_fromc_args+0x43)[0xb7baf0b3]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_ex_throw_from_c+0x1cc)[0xb7b92f1c]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7b92fb1]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bceb1a]
/home/msl/parrot/blib/lib/libp

[perl #61926] Can't declare the element type of an array or hash

2009-01-02 Thread via RT
# New Ticket Created by  Markus Laker 
# Please include the string:  [perl #61926]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=61926 >


FWIW, the first two examples look correct to me.  An undefined Int should
stringify to `Int'; a defined Int should stringify in the obvious way.

Best regards,

Markus


m...@edward:~/perl/6$ ~/bin/perl6 -e 'my Int $x; $x.say'
Int
m...@edward:~/perl/6$ ~/bin/perl6 -e 'my Int $x = 42; $x.say'
42
m...@edward:~/perl/6$ ~/bin/perl6 -e 'my Int @a'
get_iter() not implemented in class 'Integer'
current instr.: '_block14' pc 97 (EVAL_7:57)
called from Sub 'parrot;PCT;HLLCompiler;eval' pc 892 
(src/PCT/HLLCompiler.pir:508)
called from Sub 'parrot;PCT;HLLCompiler;command_line' pc 1436 
(src/PCT/HLLCompiler.pir:768)
called from Sub 'parrot;Perl6;Compiler;main' pc 19057 (perl6.pir:162)
*** glibc detected *** /home/msl/bin/perl6: double free or corruption (!prev): 
0x08455ec0 ***
=== Backtrace: =
/lib/tls/i686/cmov/libc.so.6[0xb78077cd]
/lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb780ae30]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(mem_sys_free+0x23)[0xb7bc2343]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bc2e3d]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bd023f]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_exit+0x70)[0xb7bb83e0]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bb7d46]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_ex_throw_from_c+0x61)[0xb7bb7db1]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bb7fb1]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7d18e26]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_default_get_iter+0x23)[0xb7d19de3]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_Object_get_iter+0x169)[0xb7e1ec39]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_Class_instantiate+0x318)[0xb7dd7c88]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_new_p_p_p+0xa3)[0xb7b71043]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7c00535]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bd2c09]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bd3723]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bd395c]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_runops_fromc_args+0x43)[0xb7bd40b3]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_ex_throw_from_c+0x1cc)[0xb7bb7f1c]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bb7fb1]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bf3b1a]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7dd5824]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_Class_init_pmc+0x21f)[0xb7dd641f]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(pmc_new_init+0x107)[0xb7bff1b7]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_newclass_p_p+0x58)[0xb7b717f8]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7c00535]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bd2c09]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bd3723]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bd395c]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_runops_fromc_args+0x43)[0xb7bd40b3]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_ex_throw_from_c+0x1cc)[0xb7bb7f1c]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bb7fb1]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bf3b1a]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7dd5824]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_Class_init_pmc+0x21f)[0xb7dd641f]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(pmc_new_init+0x107)[0xb7bff1b7]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_newclass_p_p+0x58)[0xb7b717f8]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7c00535]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bd2c09]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bd3723]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2[0xb7bd395c]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_runops_fromc_args+0x43)[0xb7bd40b3]
/home/msl/parrot/blib/lib/libparrot.so.0.8.2(Parrot_runcode+0x269)[0xb7bb4519]
/home/msl/bin/perl6[0x8048a18]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xdc)[0xb77b5ebc]
/home/msl/bin/perl6[0x8048851]
=== Memory map: 
08048000-08263000 r-xp  08:01 8586467
/home/msl/parrot/languages/perl6/perl6
08263000-08264000 rw-p 0021a000 08:01 8586467
/home/msl/parrot/languages/perl6/perl6
08264000-086ea000 rw-p 08264000 00:00 0  [heap]
b6536000-b653b000 r--s  08:01 8539484
/home/msl/parrot/runtime/parrot/library/P6object.pbc
b663c000-b6669000 r--s  08:01 8539304
/home/msl/parrot/runtime/parrot/library/PGE.pbc
b6669000-b666b000 r--s  08:01 8539591
/home/msl/parrot/runtime/parrot/library/PCT/Grammar.pbc
b666b000-b666c000 r--s  08:01 8539589
/home/msl/parrot/runtime/parrot/library/PCT.pbc
b704b000-b705 r--s  08:01 8539478
/home/msl/parrot/runtime/parrot/library/Getopt/Obj.pbc
b705-b7073000 r--s  08:01 8539590
/home/msl/parrot/runtime/parrot/libra

[perl #61930] [PATCH] More tests in 04-op-cmp.t

2009-01-02 Thread Kyle Hasselbacher
# New Ticket Created by  "Kyle Hasselbacher" 
# Please include the string:  [perl #61930]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=61930 >


I don't know why '1 < 2' would work but '2 < 1' would not work, but
this tests for that and similar things that weren't tested before.

I don't know if this is a good place to test 'cmp' and '<=>' too, but
that would be easy enough to add.

Index: t/00-parrot/04-op-cmp.t
===
--- t/00-parrot/04-op-cmp.t (revision 34836)
+++ t/00-parrot/04-op-cmp.t (working copy)
@@ -4,7 +4,7 @@

 use v6;

-say '1..24';
+say '1..56';

 1 < 2 and say 'ok 1';
 1 > 2 or say 'ok 2';
@@ -31,3 +31,42 @@
 'd' gt 'c' gt 'c' or say 'ok 22';
 'a' ne 'b' and say 'ok 23';
 'a' ne 'a' or say 'ok 24';
+
+2 < 1 or say 'ok 25';
+2 > 1 and say 'ok 26';
+2 <= 1 or say 'ok 27';
+2 >= 1 and say 'ok 28';
+1 <= 1 and say 'ok 29';
+1 >= 1 and say 'ok 30';
+
+1 <= 2 <= 3 and say 'ok 31';
+1 <= 1 <= 3 and say 'ok 32';
+1 <= 1 <= 1 and say 'ok 33';
+3 >= 2 >= 1 and say 'ok 34';
+3 >= 3 >= 1 and say 'ok 35';
+3 >= 3 >= 3 and say 'ok 36';
+
+2 <= 1 <= 1 or say 'ok 37';
+1 <= 2 <= 1 or say 'ok 38';
+1 >= 1 >= 2 or say 'ok 39';
+1 >= 2 >= 1 or say 'ok 40';
+
+'b' lt 'a' or say 'ok 41';
+'b' gt 'a' and say 'ok 42';
+'b' le 'a' or say 'ok 43';
+'b' ge 'a' and say 'ok 44';
+'a' le 'a' and say 'ok 45';
+'a' ge 'a' and say 'ok 46';
+
+'a' le 'b' le 'c' and say 'ok 47';
+'a' le 'a' le 'c' and say 'ok 48';
+'a' le 'a' le 'a' and say 'ok 49';
+'c' ge 'b' ge 'a' and say 'ok 50';
+'c' ge 'c' ge 'a' and say 'ok 51';
+'c' ge 'c' ge 'c' and say 'ok 52';
+
+'b' le 'a' le 'a' or say 'ok 53';
+'a' le 'b' le 'a' or say 'ok 54';
+'a' ge 'a' ge 'b' or say 'ok 55';
+'a' ge 'b' ge 'a' or say 'ok 56';
+


Re: [perl #61904] [BUG] r34778 - code takes forever

2009-01-02 Thread Mark A. Hershberger
Sorry for not finding the specific problem before.

> while($not_prime && $!number++) {
>   $not_prime = @!primes.grep({$!number % $^a == 0});
> }

The problem with Rakudo is that it is setting @!primes to a list
containing a single item (the latest value of $!number) on each turn
through the loop.

Saying $not_prime after the expression: 

> while($not_prime && $!number++) {
>   $not_prime = @!primes.grep({$!number % $^a == 0});
>   say $not_prime;
> }

shows $not_prime is being set to the current value of $!number. And of
course, since $not_prime is always true, the loop never exits.

What I don't understand it why it works on the first time through, but
never after that.

Oh, as an added bonus, adding the say causes a segfault.


[perl #61914] [BUG] Declarator Parser Failure if Whitespace after Opening Paren

2009-01-02 Thread publiustemp-perl6compil...@yahoo.com (via RT)
# New Ticket Created by  publiustemp-perl6compil...@yahoo.com 
# Please include the string:  [perl #61914]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=61914 >


This works fine:

  class Foo {
  has ($.this,
  $.that,
  );
  }
  my Foo $foo .= new( this => 3, that => 4 );
  say $foo.this;

 
However, any whitespace after the opening paren causes a parse failure:

  class Foo {
  has ($.this,
  $.that,
  );
  }
  my Foo $foo .= new( this => 3, that => 4 );
  say $foo.this;

Unable to parse declarator; couldn't find final ')' at line 4, near "$.this, \n 
"

current instr.: 'parrot;PGE;Util;die' pc 129 
(runtime/parrot/library/PGE/Util.pir:83)
called from Sub 'parrot;Perl6;Grammar;declarator' pc 81845 
(src/gen_grammar.pir:23527)
called from Sub 'parrot;Perl6;Grammar;scoped' pc 82534 
(src/gen_grammar.pir:23780)
called from Sub 'parrot;Perl6;Grammar;scope_declarator' pc 83560 
(src/gen_grammar.pir:24183)
called from Sub 'parrot;Perl6;Grammar;noun' pc 70435 (src/gen_grammar.pir:19268)
called from Sub 'parrot;Perl6;Grammar;expect_term' pc 65600 
(src/gen_grammar.pir:17435)
called from Sub 'parrot;PGE;OPTable;parse' pc 1988 
(compilers/pge/PGE/OPTable.pir:566)
called from Sub 'parrot;Perl6;Grammar;statement' pc 29622 
(src/gen_grammar.pir:3674)
called from Sub 'parrot;Perl6;Grammar;statementlist' pc 27358 
(src/gen_grammar.pir:2799)
called from Sub 'parrot;Perl6;Grammar;statement_block' pc 24895 
(src/gen_grammar.pir:1841)
called from Sub 'parrot;Perl6;Grammar;block' pc 26388 (src/gen_grammar.pir:2419)
called from Sub 'parrot;Perl6;Grammar;package_block' pc 79263 
(src/gen_grammar.pir:22572)
called from Sub 'parrot;Perl6;Grammar;package_def' pc 77242 
(src/gen_grammar.pir:21820)
called from Sub 'parrot;Perl6;Grammar;package_declarator' pc 75576 
(src/gen_grammar.pir:21207)
called from Sub 'parrot;Perl6;Grammar;noun' pc 70330 (src/gen_grammar.pir:19233)
called from Sub 'parrot;Perl6;Grammar;expect_term' pc 65600 
(src/gen_grammar.pir:17435)
called from Sub 'parrot;PGE;OPTable;parse' pc 1988 
(compilers/pge/PGE/OPTable.pir:566)
called from Sub 'parrot;Perl6;Grammar;statement' pc 29622 
(src/gen_grammar.pir:3674)
called from Sub 'parrot;Perl6;Grammar;statementlist' pc 27358 
(src/gen_grammar.pir:2799)
called from Sub 'parrot;Perl6;Grammar;statement_block' pc 24895 
(src/gen_grammaruse v6;

This is r34828
$ uname -a
Darwin curtis-poes-computer-3.local 9.5.1 Darwin Kernel Version 9.5.1: Fri Sep 
19 16:19:24 PDT 2008; root:xnu-1228.8.30~1/RELEASE_I386 i386

Cheers,
Ovid
--
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog- http://use.perl.org/~Ovid/journal/
Twitter  - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6



[Parrot] New comment on Solutions to the Exercises in Episode 4.

2009-01-02 Thread Rolf
Rolf has left a new comment on your post "Solutions to the Exercises in
Episode 4":

The global $?BLOCK variable you're using in the exception rule is only
introduced in Episode 5 of this tutorial. As a result, your solution to
implementing the try statement can't be easily applied to the code I
have after Episode 4. By removing the 2 lines referencing $?BLOCK, I
get some working code, but I'm not quite sure whether it's also correct.



Posted by Rolf to Parrot at January 2, 2009 2:00 PM

Re: [perl #61904] [BUG] r34778 - code takes forever

2009-01-02 Thread Andy_Bach
class Prime {
  has @!primes is rw;
  has Int $!number is rw = 1;

  method next() {
my $not_prime = 1;

while($not_prime && $!number++) {
  $not_prime = @!primes.grep({$!number % $^a == 0});
}

Appears that last assignment changes $not_prime.WHAT from "Int" into
"Array".

a
---
Andy Bach
Systems Mangler
Internet: andy_b...@wiwb.uscourts.gov
Voice: (608) 261-5738; Cell: (608) 658-1890

Straw? No, too stupid a fad. I put soot on warts.



[perl #61928] [BUG] (undef === undef)

2009-01-02 Thread via RT
# New Ticket Created by  Todd Hepler 
# Please include the string:  [perl #61928]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=61928 >


Hi.

I think this is a bug, but I'm not sure.

(undef === undef) currently evaluates to false.  Seem like it should be 
true.

I couldn't find a test for it, so below is a patch to add one.

Thanks,
-Todd


=== t/spec/S03-operators/value_equivalence.t
==
--- t/spec/S03-operators/value_equivalence.t(revision 114804)
+++ t/spec/S03-operators/value_equivalence.t(local)
@@ -14,7 +14,7 @@

  =end pod

-plan 51;
+plan 52;

  # === on values
  {
@@ -25,6 +25,7 @@
ok !("abc" === "ABC"), "=== on values(abc === ABC)";
ok !(1 === 1.0), "=== on values (1 === 1.0)";
ok !(1 === "1"), '=== on values (1 === "1")';
+  ok (undef === undef), '=== on values (undef === undef)';
  }

  # Value types


Re: Converting a Perl 5 "pseudo-continuation" to Perl 6

2009-01-02 Thread Geoffrey Broadwell
On Fri, 2009-01-02 at 22:56 +0100, Aristotle Pagaltzis wrote:
> > When I asked this question on #perl6, pmurias suggested using
> > gather/take syntax, but that didn't feel right to me either --
> > it's contrived in a similar way to using a one-off closure.
> 
> Contrived how?

Meaning, the gather/take syntax doesn't make much sense, because we're
not "gathering" anything; the PID file handler has nothing to return.
We'd only be using it for the "side effect" of being able to pause the
callee's execution and resume it later.

> When you have an explicit entity representing the continuation,
> all of these questions resolve themselves in at once: all calls
> to the original routine create a new continuation, and all calls
> via the state object are resumptions. There is no ambiguity or
> subtlety to think about.

I like this argument.  I'm not sure it's applicable in every case, but
it certainly applies to the class of situations containing my problem.

> So from the perspective of the caller, I consider the “one-off”
> closure ideal: the first call yields an object that can be used
> to resume the call.
> 
> However, I agree that having to use an extra block inside the
> routine and return it explicity is suboptimal. It would be nice
> if there was a `yield` keyword that not only threw a resumable
> exception, but also closed over the exception object in a
> function that, when called, resumes the original function.
> 
> That way, you get this combination:
> 
> sub pid_file_handler ( $filename ) {
> # ... top half ...
> yield;
> # ... bottom half ...
> }
> 
> sub init_server {
> # ...
> my $write_pid = pid_file_handler( $options );
> become_daemon();
> $write_pid();
> # ...
> }

That's pretty nice.  Perhaps we can make it even cleaner with a few
small tweaks to init_server():

sub init_server(:$pid_file, ...) {
# ...
my &write_pid := pid_file_handler($pid_file);
become_daemon();
write_pid();
# ...
}

So far, this variant is winning for me, I think.  It's slightly more
verbose on the caller's side than the yield variant I had proposed, but
it's also more explicit, and allows (as you said) a clean syntactic
separation between starting the PID file handler and continuing it.

It does bring up a question, though.  What if pid_file_handler() needed
to be broken into three or more pieces, thus containing multiple yield
statements?  Does only the first one return a continuation object, which
can be called repeatedly to continue after each yield like this?

sub init_server(:$pid_file, ...) {
# ...
my &more_pid_stuff := pid_file_handler($pid_file);
become_daemon();

more_pid_stuff();
do_something();

more_pid_stuff();
do_something_else();

more_pid_stuff();
# ...
}

Or does each yield produce a fresh new continuation object like this?

sub init_server(:$pid_file, ...) {
# ...
my &write_pid   := pid_file_handler($pid_file);
become_daemon();

my &fold_pid:= write_pid();
do_something();

my &spindle_pid := fold_pid();
do_something_else();

spindle_pid();
# ...
}

(Note that I assume you can simply ignore the returned object if you
don't plan to continue the operation any more, without raising a
warning.)

Certainly the first version has less visual clutter, so I tend to lean
that way by default.  But the second design would allow one to create a
tree of partial executions, by calling any earlier continuation object
again.  That's a very powerful concept that I don't want to give up on.

Supporting both feels like it might be an adverb on the invocation
(possibly with a frosty sugar coating available).  It would be nice to
support invoking a continuation in "ratcheting" and "forgetful" modes.

Thoughts?


-'f




Re: r24737 - docs/Perl6/Spec

2009-01-02 Thread Geoffrey Broadwell
On Fri, 2009-01-02 at 12:27 -0800, jerry gay wrote:
> oh, yes, whoops! i responded to someone else in #pugs earlier, and
> forgot to address the item here. C replaces p5's
> C (that's the latest idea from damian, although it seems not
> to be published yet).

Ah, I get it!  What about perldoc's special modes?  Will these go in
++DOC ... ++/DOC sections?

> the most likely short names, C<< < -d -o -c > >> are all taken by
> either p5 or p6 command-line. i don't want to use C<-d>, because that
> has to do with the debugger in p5, so makes it harder for p6 to catch
> accidental usage. C<--doc> probably warrants a short name, since it
> will be called frequently--i hope, reducing irc traffic :) but i
> haven't decided on a good name yet. i'm open to suggestions.

Don't have any yet.  Will let my subconcious ruminate on it.


-'f




Re: Converting a Perl 5 "pseudo-continuation" to Perl 6

2009-01-02 Thread Mark J. Reed
On Fri, Jan 2, 2009 at 9:06 PM, Geoffrey Broadwell  wrote:
> It does bring up a question, though.  What if pid_file_handler() needed
> to be broken into three or more pieces, thus containing multiple yield
> statements?  Does only the first one return a continuation object, which
> can be called repeatedly to continue after each yield like this?

IMO, that's not much better than not having the explicit continuation
object in the first place.  A true continuation should essentially be
an immutable value object that can be repeatedly invoked to resume
processing at the same point.

>my &more_pid_stuff := pid_file_handler($pid_file);

How does binding work with an rvalue like that?

> Or does each yield produce a fresh new continuation object like this?

That would definitely be my vote.

-- 
Mark J. Reed 


Re: r24737 - docs/Perl6/Spec

2009-01-02 Thread jason switzer
On Fri, Jan 2, 2009 at 8:12 PM, Geoffrey Broadwell wrote:

> On Fri, 2009-01-02 at 12:27 -0800, jerry gay wrote:
> > oh, yes, whoops! i responded to someone else in #pugs earlier, and
> > forgot to address the item here. C replaces p5's
> > C (that's the latest idea from damian, although it seems not
> > to be published yet).
>
> Ah, I get it!  What about perldoc's special modes?  Will these go in
> ++DOC ... ++/DOC sections?


Jerry mentioned in IRC that he intends on documenting the metasyntax options
more. I'm guessing this is sort of a special meta argument given perldoc's
modes, so it should probably be documented there. I would like to raise the
question of whether implementations must be required to fully parse/present
perldoc or just recognize it's presence. This would allow for POD "fluffers"
like pod2html and for streamlined perl6 implementations to skip things like
--doc.

-Jason "s1n" Switzer


Re: Converting a Perl 5 "pseudo-continuation" to Perl 6

2009-01-02 Thread Larry Wall
On Fri, Jan 02, 2009 at 06:06:31PM -0800, Geoffrey Broadwell wrote:
: Meaning, the gather/take syntax doesn't make much sense, because we're
: not "gathering" anything; the PID file handler has nothing to return.
: We'd only be using it for the "side effect" of being able to pause the
: callee's execution and resume it later.

Leaving aside for the moment the question of how much we want mere
mortals to know about continuations when normal closures would do,
I think you're falling into a kind of P5Think here, that all forms
of nothing are equivalent.  A take always returns a Capture object,
so at minimum you're gathering a list of Captures, even if they're
empty.  If you like, you could also think of gathering continuations
or closures, depending on whether the object you take closes over
return context or just the rest of the current call.

In any case, I dislike the overloading of the function interface that
happens with many standard coroutine designs.  That's why gather/take
is orthogonal to the function call interface.

As for syntactic relief, that will always be a macro away in Perl 6,
if you really want it.  But I think "return {...}" and "take {...}"
are nice, explicit idioms for returning a closure, and we've gone to
some pains in Perl 6 to make a bare block behave that way without a
keyword, so I'm not in a hurry to huffmanize away a mere two characters
for what what many readers would view as a form of obfuscation.

As for true reusable continuations, I'm not opposed to having them
available in the language per se, but they're hard to implement on some
architectures, and I'll certainly frown on any attempt to confuse them
with either normal closures or even single-use continuations in the
minds of mere mortals.  Using bare continuations where gather/take or
closures will do is like throwing out your steak knives because they
duplicate the functionality of your chain saw.  :)

Larry