Re: Support for ensuring invariants from one loop iteration to the next?

2008-12-19 Thread Aristotle Pagaltzis
* Jon Lang  [2008-12-19 03:50]:
> Personally, it doesn’t strike me as being as straightforward
> as putting a “last unless” clause into the middle of an
> otherwise-infinite loop

You have to keep more state in your head to read

while(1) {
# ...
last if $foo;
}

than to read

while($foo) {
# ...
}

The goto in the code I gave happens just once and doesn’t modify
the loop semantics. Basically, any one point in the code I gave
can be read in isolation, and is “locally complete” (I don’t know
how to say this better), whereas in the infinite loop the overall
effect of certain points is depenent on other points.

In Schwern’s terms, goto’ing into the middle of a terminating
loop is more skimmable than last’ing out of the middle of an
infinite loop.

Regards,
-- 
Aristotle Pagaltzis // 


Re: Support for ensuring invariants from one loop iteration to the next?

2008-12-19 Thread Jon Lang
Like I said: if the goto approach works for you, more power to you.  Me, I find:

   loop {
   @stuff = grep { $_->valid } @stuff;
   TEST: last unless @stuff;

   $_->do_something( ++$i ) for @stuff;
   }

to be at least as straightforward as:

   goto INVARIANT;

   while ( @stuff ) {
   $_->do_something( ++$i ) for @stuff;

   INVARIANT:
   @stuff = grep { $_->valid } @stuff;
   }

It strikes me as being more concise; and the use of the (superfluous)
label makes the position and significance of the "last unless..." line
stand out.

I'm not telling you that you're wrong; TIMTOWTDI.  I'm telling you
that it's a matter of taste.

On Fri, Dec 19, 2008 at 5:52 AM, Aristotle Pagaltzis  wrote:
> * Jon Lang  [2008-12-19 03:50]:
>> Personally, it doesn't strike me as being as straightforward
>> as putting a "last unless" clause into the middle of an
>> otherwise-infinite loop
>
> You have to keep more state in your head to read
>
>while(1) {
># ...
>last if $foo;
>}
>
> than to read
>
>while($foo) {
># ...
>}
>
> The goto in the code I gave happens just once and doesn't modify
> the loop semantics. Basically, any one point in the code I gave
> can be read in isolation, and is "locally complete" (I don't know
> how to say this better), whereas in the infinite loop the overall
> effect of certain points is depenent on other points.
>
> In Schwern's terms, goto'ing into the middle of a terminating
> loop is more skimmable than last'ing out of the middle of an
> infinite loop.
>
> Regards,
> --
> Aristotle Pagaltzis // 
>



-- 
Jonathan "Dataweaver" Lang


r24493 - docs/Perl6/Spec

2008-12-19 Thread pugs-commits
Author: pmichaud
Date: 2008-12-19 19:35:40 +0100 (Fri, 19 Dec 2008)
New Revision: 24493

Modified:
   docs/Perl6/Spec/S26-documentation.pod
Log:
Add note at top that the current S26 draft is known to be out-of-date
with respect to current design.


Modified: docs/Perl6/Spec/S26-documentation.pod
===
--- docs/Perl6/Spec/S26-documentation.pod   2008-12-19 16:52:36 UTC (rev 
24492)
+++ docs/Perl6/Spec/S26-documentation.pod   2008-12-19 18:35:40 UTC (rev 
24493)
@@ -22,7 +22,16 @@
 Date:   9 Apr 2005
 Last Modified:  25 Apr 2007
 
+=head1 NOTE TO IMPLEMENTORS AND CODERS (DRAFT!)
 
+ DRAFT DRAFT DRAFT DRAFT DRAFT DRAFT DRAFT
+
+The information that is in this file is a draft specification that
+is known to be out of date and likely to undergo some substantial
+revision.  Until the document is updated, look at STD.pm
+(http://svn.pugscode.org/pugs/src/perl6/STD.pm) for the valid
+POD syntax.
+
 =head1 Perldoc
 
 Perldoc is an easy-to-use markup language with a simple, consistent



r24501 - docs/Perl6/Spec

2008-12-19 Thread pugs-commits
Author: particle
Date: 2008-12-19 23:06:58 +0100 (Fri, 19 Dec 2008)
New Revision: 24501

Modified:
   docs/Perl6/Spec/S19-commandline.pod
Log:
[spec] updates to notes, and minor clarifications

Modified: docs/Perl6/Spec/S19-commandline.pod
===
--- docs/Perl6/Spec/S19-commandline.pod 2008-12-19 22:06:16 UTC (rev 24500)
+++ docs/Perl6/Spec/S19-commandline.pod 2008-12-19 22:06:58 UTC (rev 24501)
@@ -27,13 +27,10 @@
 the compiler and the operating system's command line shell, and thus is not
 accessed via a consistent syntax everywhere. Perl is born of Unix, and as such
 the syntax presented in this document is expected to work in a Unix-style
-shell. To explore the particularities of other operating systems, see 
+shell. To explore the particularities of other operating systems, see
+L (TBD).
 
-{{ -jg
-need reference to 'porting' chapter or equivalent above -- S25?
-}
 
-
 =head1 Command Line Elements
 
 The command line is broken down into two basic elements: a I, and
@@ -100,8 +97,9 @@
 
 =item *
 
-The special option C<--> signals the parser to stop option processing,
-everything afterwards is parsed as a value.
+The special option C<--> signals the parser to stop option processing.
+Arguments following C<--> are always parsed as a list of values, even if
+they look like valid options.
 
 =back
 
@@ -278,6 +276,10 @@
 
 Service: Option
 
+Notes: When this option is parsed, it immediately triggers an action that
+could affect the remainder of the parse. Therefore, it's a good idea to put
+this option/value pair as early as possible in the argument list.
+
 {{ TODO more details needed }}
 
 =item -c
@@ -502,15 +504,10 @@
 
 do i need to address any unicode concerns?
 
-loading a switch parsing module by a switch, instead of using the default.
-maybe via ++RTS, since it needs to happen *before* switches are evaluated.
-
 sandboxing? maybe-r
 
 env var? maybe -E
 
-redefining services like -n or -p
-
 -e multiple args or multiple times, to affect later -e's
 }}
 



r24504 - docs/Perl6/Spec

2008-12-19 Thread pugs-commits
Author: lwall
Date: 2008-12-19 23:58:28 +0100 (Fri, 19 Dec 2008)
New Revision: 24504

Modified:
   docs/Perl6/Spec/S12-objects.pod
Log:
[S12] clarify $obje...@candidates for moritz_++


Modified: docs/Perl6/Spec/S12-objects.pod
===
--- docs/Perl6/Spec/S12-objects.pod 2008-12-19 22:20:18 UTC (rev 24503)
+++ docs/Perl6/Spec/S12-objects.pod 2008-12-19 22:58:28 UTC (rev 24504)
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall 
   Date: 27 Oct 2004
-  Last Modified: 18 Dec 2008
+  Last Modified: 19 Dec 2008
   Number: 12
-  Version: 66
+  Version: 67
 
 =head1 Overview
 
@@ -265,7 +265,7 @@
 
 $obj.$($foo ?? &bar !! &baz)(1,2,3)
 
-The variable must contain a Code object, that is, a closure of some
+The variable must contain a C object (usually of type C), that 
is, a closure of some
 sort.  Regardless of whether the closure was defined as a method or
 a sub or a block, the closure is called directly without any class
 dispatch; from the closure's point of view, however, it is always
@@ -306,14 +306,22 @@
 
 $o...@candidates(1,2,3)
 
-As with the scalar variant, each array element must be a Code object,
-but the list is treated as a list of candidates to call.  Note also that
-the 
+As with the scalar variant, string method names are not allowed, only
+C objects, The list is treated as a list of candidates to
+call.  After the first successful call the rest of the candidates are
+discarded.  Failure of the current candidate is indicated by calling
+C or C (see L below).
 
+Note also that the 
+
 $obj.$candidates(1,2,3)
 
-form may dispatch to a list of candidates if $candidates is a special
-C object representing a partial dispatch to a list of candidates.
+form may dispatch to a list of candidates if C<$candidates> is either
+a list or a special C object representing a partial dispatch to a
+list of candidates.  If C<$candidates> (or any element of C<@candidates>)
+is a List or Array object it is expanded out recursively until C
+candidates are found.  The call fails if it hits a candidate that is
+neither C nor expandable.
 
 Another form of indirection relies on the fact that operators are named
 using a variant on hash subscript notation, which gives you these forms:



r24506 - docs/Perl6/Spec

2008-12-19 Thread pugs-commits
Author: lwall
Date: 2008-12-20 03:06:20 +0100 (Sat, 20 Dec 2008)
New Revision: 24506

Modified:
   docs/Perl6/Spec/S19-commandline.pod
Log:
[S19] random annotations for [particle]++'s consideration


Modified: docs/Perl6/Spec/S19-commandline.pod
===
--- docs/Perl6/Spec/S19-commandline.pod 2008-12-19 23:21:32 UTC (rev 24505)
+++ docs/Perl6/Spec/S19-commandline.pod 2008-12-20 02:06:20 UTC (rev 24506)
@@ -31,6 +31,8 @@
 L (TBD).
 
 
+[my notes/conjectures below are all in square brackets  --TimToady]
+
 =head1 Command Line Elements
 
 The command line is broken down into two basic elements: a I, and
@@ -41,6 +43,18 @@
 Perl 6 does not do any processing of the I portion of the command
 line, but it is made available at run-time in the read-only C<$*VM> variable.
 
+[ It seems wrong to call this a I when (from the Unix point
+of view) it's just a program to run, and the compilation may have
+happened long ago.  Maybe I or I instead.  Which
+phases are invoked may well depend on the nature of the file that is
+specified as a program to be interpreted, as well as the requested
+form of output.]
+
+[ $*VM is certainly wrong for the original compiler.  It would have to
+be $?VM, though that may be wrong too.  One could imagine a particular
+compiler that ran on multiple VMs, in which case some other variable
+would be needed to indicate the original compiler.]
+
 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
@@ -49,7 +63,9 @@
 command line options together, even though this is not enforced, in order to
 avoid confusion.
 
+[ This policy may be counter-intuitive to current comand-line cultures. ]
 
+
 =head1 Backward (In)compatibility
 
 Muscles have a long memory. You may find yourself typing your favorite Perl 5
@@ -82,6 +98,11 @@
 
 Single-letter options must not be clustered. C<-ab> never means C<-a -b>
 
+[Some systems allow clustering of - options but not of -- options.  Obviously
+such systems disallow multicharacter - options and require --foo instead of
+-foo.  Another option is to allow :a:b as a form of bundling since that's
+unambiguous from a p6 point of view.]
+
 =item *
 
 Options must begin with one of the following symbols: C<< < -- - + : > >>
@@ -95,12 +116,19 @@
 
 Options may be negated with C or C, for example C<:/name>
 
+[:/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.]
+
 =item *
 
 The special option C<--> signals the parser to stop option processing.
 Arguments following C<--> are always parsed as a list of values, even if
 they look like valid options.
 
+[Distinguish here from --foo options?  "...with no identifier" or some such]
+
 =back
 
 
@@ -108,11 +136,13 @@
 delimiters on either end, allowing options to be passed through for later
 processing, and are parsed with the following rules:
 
+[ s/for later processing/to specified subsystems/ would be clearer, I think. ]
+
 =over 4
 
 =item *
 
-The opening delimeter begins with C<++>, the closing delimiter with C<-->.
+The opening delimiter begins with C<++>, the closing delimiter with C<-->.
 
 =item *
 
@@ -128,11 +158,28 @@
 run-time component. For example, C<++RTS=parser ... --RTS=parser> directs
 the delimited options to the parser (see L below).
 
+[This seems a bit bogus insofar as --RTS=parser is still officially
+ambiguous with switches inside.  Plus it's not at all clear why this
+isn't just ++PARSER ... --PARSER.  What's the parser got to do with
+the run-time system?
+
+Other options that keep the metasyntax further away from ordinary switch
+syntax:
+
+:+PARSER ... :-PARSER
+++BEGIN=PARSER ... ++END=PARSER
+++PARSER ... ++/PARSER
+
+The last one having reverberations of html tags.  But in any case
+I think I like the consistent ++ escape for metasyntax.]
+
 =item *
 
 When an optional parameter is given, it must be specified on both the opening
 and closing delimited options.
 
+[To me this just means you allow names with = in the middle.]
+
 =item *
 
 If the closing delimiter is omitted, the rest of the command line is consumed.
@@ -141,13 +188,22 @@
 
 The C<--> option has no effect within a delimited option.
 
+[How do you know?  That's up to the subprocessor, surely?  What if they
+want to treat the rest of the arguments as data even if they happen
+to start with '--'?  I think what you mean is that it does not suppress
+searching for the closer.]
+
 =item *
 
 Delimited options cannot be negated.
 
 =back
 
+[From the P6 viewpoint, these options should probably be shoved into
+context variables and be invisible to MAIN except as %+OPTS
+or @+PARSER_ARGS or some such.]
 
+
 Values are parsed with the following rules:
 
 =over 4
@@ -168,6 +224,10 @@
 M

r24508 - docs/Perl6/Spec

2008-12-19 Thread pugs-commits
Author: wayland
Date: 2008-12-20 04:44:08 +0100 (Sat, 20 Dec 2008)
New Revision: 24508

Modified:
   docs/Perl6/Spec/S22-package-format.pod
Log:
Added some definitions


Modified: docs/Perl6/Spec/S22-package-format.pod
===
--- docs/Perl6/Spec/S22-package-format.pod  2008-12-20 03:19:23 UTC (rev 
24507)
+++ docs/Perl6/Spec/S22-package-format.pod  2008-12-20 03:44:08 UTC (rev 
24508)
@@ -13,24 +13,33 @@
 
 =head1 VERSION
 
-Maintainer: Tim Nelson 
+Maintainer: Jos Boumans 
 Date: 3 Nov 2005
 Last Modified: 19 Dec 2008
 Number: 22
 Version: 2
 
-=head1 Overview
+=head1 OVERVIEW
 
-=head2 What this isn't
+=head2 Terminology and Scope
 
+I'll start by listing a few terms, and whether this document is supposed to 
cover them or 
+not.  
+
 =over
 
-=item * This does not specify repositories.  For information on that, see 
-http://cpan6.org/
+=item * .jib files; this is the source package format, and is specified in 
this document
 
-=item * This does not specify software for downloading, building, or 
installing packages.  
-For information on that, see build-and-install-notes.pod
+=item * CPAN6; this is a piece of software for managing an archive network 
(such as CPAN).  
+This is not specified in this document; see http://cpan6.org/
 
+=item * ???A; this is an actual network based on the cpan6 software (see 
above).  It also 
+is not documented here.  
+
+=item * ???B; this is a piece of software that starts with what it can get on 
???A, and 
+attempts to give you an installed perl module (this is a replacement for 
+CPANPLUS/cpan2dist)
+
 =back
 
 =head2 Inspirations
@@ -42,11 +51,13 @@
 =item * Debian Policy: http://www.us.debian.org/doc/debian-policy
 
 =item * Software::Packager::Metadata: 
-http://perlsoftpackmet.svn.sourceforge.net/viewvc/perlsoftpackmet/main/doc/ 
(click ont he 
+http://perlsoftpackmet.svn.sourceforge.net/viewvc/perlsoftpackmet/main/doc/ 
(click on the 
 link in the Rev. column next to Overview)
 
-=head1 Package Layout
+=back
 
+=head1 PACKAGE LAYOUT
+
 =head2 Project directory
 
 Step 1 of the general flow should ideally be done by an automated tool, like
@@ -113,7 +124,7 @@
 There is room to ship more files alongside the 2 above mentioned archives.
 This allows us to ship an extra md5sum, version, signature, anything.
 
-=head1 Metadata Spec
+=head1 METADATA SPEC
 
 - Define no more than needed to get started for now
 - Allow for future extensions
@@ -162,7 +173,7 @@
 
 [3] Steal more tags from debian policy
 
-=head1 Dependencies
+=head1 DEPENDENCIES
 
 =head2 Dependency Notation
 



Re: 6PAN Spec question

2008-12-19 Thread Timothy S. Nelson
	Btw, looks like I was wrong about the terminology of 
CPAN6/6PAN/whatever.  See link below for details (the new Terminology 
section).


http://svn.pugscode.org/pugs/docs/Perl6/Spec/S22-package-format.pod

:)


-
| Name: Tim Nelson | Because the Creator is,|
| E-mail: wayl...@wayland.id.au| I am   |
-

BEGIN GEEK CODE BLOCK
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- 
PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI D G+ e++> h! y-

-END GEEK CODE BLOCK-