[svn:perl6-synopsis] r14600 - doc/trunk/design/syn

2008-11-07 Thread larry
Author: larry
Date: Fri Nov  7 09:02:15 2008
New Revision: 14600

Modified:
   doc/trunk/design/syn/S02.pod

Log:
add $?VM and $?DISTRO, recast versions as object info


Modified: doc/trunk/design/syn/S02.pod
==
--- doc/trunk/design/syn/S02.pod(original)
+++ doc/trunk/design/syn/S02.podFri Nov  7 09:02:15 2008
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall [EMAIL PROTECTED]
   Date: 10 Aug 2004
-  Last Modified: 4 Nov 2008
+  Last Modified: 7 Nov 2008
   Number: 2
-  Version: 140
+  Version: 141
 
 This document summarizes Apocalypse 2, which covers small-scale
 lexical items and typological issues.  (These Synopses also contain
@@ -1967,22 +1967,10 @@
 
 Here are some possibilities:
 
-$?OSWhich operating system am I compiled for?
-$?OSVER Which operating system version am I compiled for?
-$?PERLVER   Which Perl version am I compiled for?
 $?FILE  Which file am I in?
 $?LINE  Which line am I at?
-$?PACKAGE   Which package am I in?
-@?PACKAGE   Which nested packages am I in?
-$?MODULEWhich module am I in?
-@?MODULEWhich nested modules am I in?
-$?CLASS Which class am I in? (as variable)
-@?CLASS Which nested classes am I in?
-$?ROLE  Which role am I in? (as variable)
-@?ROLE  Which nested roles am I in?
-$?GRAMMAR   Which grammar am I in?
-@?GRAMMAR   Which nested grammars am I in?
 $?PARSERWhich Perl grammar was used to parse this statement?
+$?LANG  Which Perl parser should embedded closures parse with?
 ?ROUTINE   Which routine am I in?
 @?ROUTINE   Which nested routines am I in?
 ?BLOCK Which block am I in?
@@ -1993,11 +1981,32 @@
 All the nested C@? variables are ordered from the innermost to the
 outermost, so C@?BLOCK[0] is always the same as C?BLOCK.
 
+The following return objects that contain all pertinent info; in
+particular they may be smartmatched against strings for the name and
+against version literals for the version:
+
+$?OSWhich operating system am I compiled for?
+$?DISTROWhich OS distribution am I compiling under
+$?VMWhich virtual machine am I compiling under
+$?XVM   Which virtual machine am I cross-compiling for
+$?PERL  Which Perl am I compiled for?
+$?PACKAGE   Which package am I in?
+@?PACKAGE   Which nested packages am I in?
+$?MODULEWhich module am I in?
+@?MODULEWhich nested modules am I in?
+$?CLASS Which class am I in? (as variable)
+@?CLASS Which nested classes am I in?
+$?ROLE  Which role am I in? (as variable)
+@?ROLE  Which nested roles am I in?
+$?GRAMMAR   Which grammar am I in?
+@?GRAMMAR   Which nested grammars am I in?
+
 Note that some of these things have parallels in the C* space at run time:
 
 $*OSWhich OS I'm running under
-$*OSVER Which OS version I'm running under
-$*PERLVER   Which Perl version I'm running under
+$*DISTROWhich OS distribution I'm running under
+$*VMWhich VM I'm running under
+$*PERL  Which Perl I'm running under
 
 You should not assume that these will have the same value as their
 compile-time cousins.


[svn:perl6-synopsis] r14601 - doc/trunk/design/syn

2008-11-07 Thread larry
Author: larry
Date: Fri Nov  7 09:54:43 2008
New Revision: 14601

Modified:
   doc/trunk/design/syn/S03.pod
   doc/trunk/design/syn/S12.pod

Log:
get rid of pair methods; $obj ~~ :foo($bar) now simply does $obj.foo ~~ $bar
with all other adverbial pair notations having corresponding meanings, so
you can do things like $obj ~~ :$attr and $filehandle ~~ :!s.
Note that these now call ordinary methods, so for good or ill Str now has
a bunch of single-character methods like foo.r.


Modified: doc/trunk/design/syn/S03.pod
==
--- doc/trunk/design/syn/S03.pod(original)
+++ doc/trunk/design/syn/S03.podFri Nov  7 09:54:43 2008
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall [EMAIL PROTECTED]
   Date: 8 Mar 2004
-  Last Modified: 17 Oct 2008
+  Last Modified: 7 Nov 2008
   Number: 3
-  Version: 145
+  Version: 146
 
 =head1 Overview
 
@@ -2169,16 +2169,19 @@
 
 =item *
 
-The filetest operators are gone.  We now use a CPair as either a
-pattern or a method name to get the same effect:
+The filetest operators are gone.  We now use a CPair as a
+pattern that calls an object's method:
 
 if $filename ~~ :e { say exists }
-if $filename.:e { say exists }
+
+is the same as
+
+if $filename.e { say exists }
 
 The 1st form actually translates to the latter form, so the object's
-class decides how to dispatch pair methods.  It just happens that
+class decides how to dispatch methods.  It just happens that
 CStr (filenames), CIO (filehandles), and CStatbuf (stat buffers)
-default to the expected filetest semantics, but C$regex.:i might
+default to the expected filetest semantics, but C$regex.i might
 tell you whether the regex is case insensitive, for instance.
 
 Using the pattern form, multiple tests may be combined via junctions:
@@ -2202,11 +2205,11 @@
 The advantage of the method form is that it can be used in places that
 require tighter precedence than C~~ provides:
 
-sort { $^a.:M = $^b.:M }, @files
+sort { $^a.M = $^b.M }, @files
 
 though that's a silly example since you could just write:
 
-sort { .:M }, @files
+sort { .M }, @files
 
 But that demonstrates the other advantage of the method form, which is
 that it allows the unary dot syntax to test the current topic.
@@ -2227,7 +2230,9 @@
 C.file attempts to return C.io.file.
 
 Note that C:s still returns the filesize, but C:!s is true
-only if the file is of size 0.
+only if the file is of size 0, since it is smartmatched
+against the implicit False argument.  By the same token,
+C:s(0..1024) will be true only for files of size 1K or less.
 
 (Inadvertent use of the PerlĀ 5 forms will normally result in treatment
 as a negated postdeclared subroutine, which is likely to produce an
@@ -2996,7 +3001,7 @@
 Any   Num   numeric equality+$_ == X
 Any   Str   string equality ~$_ eq X
 
-Any   Pair  test object .:Xkey(Xval) (e.g. filetests)
+Any   Pair  test object attribute   .Xkey ~~ Xval (e.g. filetests)
 
 Set   Set   identical sets  $_ === X
 Hash  Set   hash keys same set  $_.keys === X

Modified: doc/trunk/design/syn/S12.pod
==
--- doc/trunk/design/syn/S12.pod(original)
+++ doc/trunk/design/syn/S12.podFri Nov  7 09:54:43 2008
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall [EMAIL PROTECTED]
   Date: 27 Oct 2004
-  Last Modified: 14 Oct 2008
+  Last Modified: 7 Nov 2008
   Number: 12
-  Version: 64
+  Version: 65
 
 =head1 Overview
 
@@ -731,20 +731,6 @@
 
 my Dog $spot .= new(:tailLONG :legsSHORT);
 
-=head1 Pair query methods
-
-Certain classes such as filehandles allow colon pairs to be used as if they
-were methods.  Method names beginning with a colon:
-
-$filehandle.:e
-$filehandle.:!x
-
-are expected to return a value that can be used as a boolean.
-While this is primarily intended for use by file tests, other classes
-may define such methods to provide a similar mechanism for interrogating
-properties.  (Also note that syntactic category names are reserved for
-calling operators as if they were methods.)
-
 =head1 Calling sets of methods
 
 For any method name, there may be some number of candidate methods


[svn:perl6-synopsis] r14602 - doc/trunk/design/syn

2008-11-07 Thread larry
Author: larry
Date: Fri Nov  7 10:10:52 2008
New Revision: 14602

Modified:
   doc/trunk/design/syn/S02.pod

Log:
recast $?FOO matching in terms of new pair matching syntax


Modified: doc/trunk/design/syn/S02.pod
==
--- doc/trunk/design/syn/S02.pod(original)
+++ doc/trunk/design/syn/S02.podFri Nov  7 10:10:52 2008
@@ -14,7 +14,7 @@
   Date: 10 Aug 2004
   Last Modified: 7 Nov 2008
   Number: 2
-  Version: 141
+  Version: 142
 
 This document summarizes Apocalypse 2, which covers small-scale
 lexical items and typological issues.  (These Synopses also contain
@@ -1981,9 +1981,7 @@
 All the nested C@? variables are ordered from the innermost to the
 outermost, so C@?BLOCK[0] is always the same as C?BLOCK.
 
-The following return objects that contain all pertinent info; in
-particular they may be smartmatched against strings for the name and
-against version literals for the version:
+The following return objects that contain all pertinent info:
 
 $?OSWhich operating system am I compiled for?
 $?DISTROWhich OS distribution am I compiling under
@@ -2001,6 +1999,20 @@
 $?GRAMMAR   Which grammar am I in?
 @?GRAMMAR   Which nested grammars am I in?
 
+It is relatively easy to smartmatch these constant objects
+against pairs to check various attributes such as name,
+version, or authority:
+
+given $?VM {
+when :nameParrot :ver(v2) { ... }
+when :nameCLOS{ ... }
+when :nameSpiderMonkey{ ... }
+when :nameJVM :ver(v6.*)  { ... }
+}
+
+Matches of constant pairs on constant objects may all be resolved at
+compile time, so dead code can be eliminated by the optimizer.
+
 Note that some of these things have parallels in the C* space at run time:
 
 $*OSWhich OS I'm running under


File test ops as string methods

2008-11-07 Thread Mark J. Reed
I'm sure this has been hashed out somewhere I wasn't looking, but i
would really prefer for pathname ops not to be mixed in to the Str
class.  Maybe they could be put in a Pathname subclass of Str, with a
simple literal syntax or short unary operator to build such a thing
from a string?


-- 
Sent from Gmail for mobile | mobile.google.com

Mark J. Reed [EMAIL PROTECTED]


Re: File test ops as string methods

2008-11-07 Thread Brandon S. Allbery KF8NH

On 2008 Nov 7, at 17:49, Mark J. Reed wrote:

I'm sure this has been hashed out somewhere I wasn't looking, but i
would really prefer for pathname ops not to be mixed in to the Str
class.  Maybe they could be put in a Pathname subclass of Str, with a
simple literal syntax or short unary operator to build such a thing
from a string?



I'm inclined to agree that Str is the wrong place for them.  I could  
see Str being autoconverted to some kind of File class which had them,  
though.


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH




Re: File test ops as string methods

2008-11-07 Thread Larry Wall
On Fri, Nov 07, 2008 at 05:49:54PM -0500, Mark J. Reed wrote:
: I'm sure this has been hashed out somewhere I wasn't looking, but i
: would really prefer for pathname ops not to be mixed in to the Str
: class.  Maybe they could be put in a Pathname subclass of Str, with a
: simple literal syntax or short unary operator to build such a thing
: from a string?

I've been thinking about that.  One interesting ramification of
the current matching rule is that you could say either of:

foo.io ~~ :r :x

or

foo ~~ :io(:r :x)

where .io is whatever your casting method of choice is for turning
a string into an object with the correct methods.  Somehow I think
.filename is a bit too long, huffmanwise.

Larry


[svn:perl6-synopsis] r14603 - doc/trunk/design/syn

2008-11-07 Thread larry
Author: larry
Date: Fri Nov  7 16:04:15 2008
New Revision: 14603

Modified:
   doc/trunk/design/syn/S03.pod

Log:
smartmatch of Hash against Pair should match against both key and value


Modified: doc/trunk/design/syn/S03.pod
==
--- doc/trunk/design/syn/S03.pod(original)
+++ doc/trunk/design/syn/S03.podFri Nov  7 16:04:15 2008
@@ -3001,6 +3001,7 @@
 Any   Num   numeric equality+$_ == X
 Any   Str   string equality ~$_ eq X
 
+Hash  Pair  test hash mapping   $_{Xkey} ~~ Xval (e.g. 
filetests)
 Any   Pair  test object attribute   .Xkey ~~ Xval (e.g. filetests)
 
 Set   Set   identical sets  $_ === X


[svn:perl6-synopsis] r14604 - doc/trunk/design/syn

2008-11-07 Thread larry
Author: larry
Date: Fri Nov  7 18:00:20 2008
New Revision: 14604

Modified:
   doc/trunk/design/syn/S03.pod

Log:
copy/paste error


Modified: doc/trunk/design/syn/S03.pod
==
--- doc/trunk/design/syn/S03.pod(original)
+++ doc/trunk/design/syn/S03.podFri Nov  7 18:00:20 2008
@@ -3001,7 +3001,7 @@
 Any   Num   numeric equality+$_ == X
 Any   Str   string equality ~$_ eq X
 
-Hash  Pair  test hash mapping   $_{Xkey} ~~ Xval (e.g. 
filetests)
+Hash  Pair  test hash mapping   $_{Xkey} ~~ Xval
 Any   Pair  test object attribute   .Xkey ~~ Xval (e.g. filetests)
 
 Set   Set   identical sets  $_ === X


More about arrayref/hashref in spectest suite

2008-11-07 Thread Patrick R. Michaud
I'm still working on issues with arrayrefs and hashrefs in
the spectest suite.  S02-literals/autoref.t:59 has the
following:

  # Implicit referentiation of arrays in assignment to an array element
  {
  my @array = a b c;
  my @other;
  @other[1] = @array;
  
  is [EMAIL PROTECTED], a b c, '@other[$idx] = @array works (1)';
  is [EMAIL PROTECTED],   2, '@other[$idx] = @array works (2)';
  is [EMAIL PROTECTED],3, '@other[$idx] = @array works (3)';
  }

The idea given by the test appears to be that the 
C @other[1] = @array;   statement causes @other[1] to
contain a reference to @array.  After the statement, @other
contains two elements, the second of which is an array of three
elements.

However, S03 and STD.pm seem to indicate that having @other[1]
on the left would result in a list assignment, not an item
assignment.  As a list assignment, @other[1] would then get
the first element from @array, and we'd get a warning about
the leftover elements.

By way of illustration, contrast the two assignments at
the end of the following code:

my @x = a b;
my @y;

@y[1] = @x, 'c';
@y[1,2,3] = @x, 'c';

The second assignment would seem to clearly be a list
assignment, leaving @y with (undef, 'a', 'b', 'c').

But is the first assignment parsed as an item assignment or
a list assignment?  If it is parsed as an item assignment,
how does the parser recognize it as such?  If it's parsed 
as a list assignment, then should we be creating an
Array reference here or merely assigning elements to
the container on the left?

Or am I missing something else altogether?

Thanks in advance for any answers,

Pm