Re: S5 - Question about repetition qualifier

2006-04-26 Thread Markus Laire
On 4/26/06, Joe Gottman <[EMAIL PROTECTED]> wrote:
> According to Synopsis 5, the repetition qualifier is now **{.} where the .
> must correspond to either an Int or a Range.  This seems rather restrictive.
> Why are we not allowed a junction of Ints, for instance

S05 also says:

It is illegal to return a list, so this easy mistake fails:
 / [foo]**{1,3} /
(At least, it fails in the absence of use rx :listquantifier, which is
likely to be unimplemented in Perl 6.0.0 anyway).


So it seems only reason not to allow lists is that they aren't yet
implemented, and likely won't be for some time.

> Also, I don't know exactly what the syntax looks like, but I can imagine
> using a repetition qualifier that takes a closure of some sort, for instance
> to match an odd number of repetitions
> m/^ a**{($_ % 2 == 0)} $/; #I'm not sure about the syntax for the code.

Are you reading some old version of S05?
http://dev.perl.org/perl6/doc/design/syn/S05.html says that "The
repetition specifier is now **{...} for maximal matching, with a
corresponding **{...}? for minimal matching. Space is allowed on
either side of the asterisks. The curlies are taken to be a closure
returning an Int or a Range object. "

So you can just put any closure which returns Int or Range directly
within the curlies.

--
Markus Laire


Re: S5 - Question about repetition qualifier

2006-04-26 Thread james
On Tue, Apr 25, 2006 at 09:57:58PM -0400, Joe Gottman wrote:
> According to Synopsis 5, the repetition qualifier is now **{.} where the .
> must correspond to either an Int or a Range.  This seems rather restrictive.
> Why are we not allowed a junction of Ints, for instance 
> 
> m/^ a**{1|3|5} $/ ; # Match 1,3, or 5 a's.

It would seem to me that the Right Thing is for the closure to return
something to ~~ against.  However, this obviously means that the regex
engine is going to have a harder time optimizing, and be somewhat more
complex, since it has to keep calling out to the smartmatcher.

Possibly we should make the syntax be a smart match, but only require that
conformat implementations implement ranges and integers.

 -=- James Mastros


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

2006-04-26 Thread autrijus
Author: autrijus
Date: Wed Apr 26 07:12:51 2006
New Revision: 8953

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

Log:
* S03: particle++ noted the omission of prefix unary
   = and -e -w -x etc from the operator table.

Modified: doc/trunk/design/syn/S03.pod
==
--- doc/trunk/design/syn/S03.pod(original)
+++ doc/trunk/design/syn/S03.podWed Apr 26 07:12:51 2006
@@ -782,7 +782,7 @@
 method postfix  . .+ .? .* .() .[] .{} .«» .=
 autoincrement   ++ --
 exponentiation  **
-symbolic unary  ! + - ~ ? $ @ % & * ** +^ ~^ ?^ \ ^
+symbolic unary  ! + - ~ ? $ @ % & * ** +^ ~^ ?^ \ ^ = -e -r -w -x etc.
 multiplicative  * / % x xx +& +< +> ~& ~< ~>
 additive+ - ~ +| +^ ~| ~^
 junctive and (all)  &


Re: S5 - Question about repetition qualifier

2006-04-26 Thread Larry Wall
On Wed, Apr 26, 2006 at 11:36:50AM +0100, [EMAIL PROTECTED] wrote:
: Possibly we should make the syntax be a smart match, but only require that
: conformat implementations implement ranges and integers.

That is essentially the intent of the current spec, and why we defined
**{} to run a closure.  It may well be trivial to make it a smart
match by 6.0.0 since we've got smart matches elsewhere.  But the
regex engine also has to be low-level enough to bootstrap Perl 6.
On the other hand, there's no need to define a limited language--the
bootstrap can just use a subset of Perl 6 by convention.  If I had to
guess, I'd say it's actually quite likely to smartmatch by 6.0.0.

Larry


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

2006-04-26 Thread autrijus
Author: autrijus
Date: Wed Apr 26 09:36:05 2006
New Revision: 8957

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

Log:
* S02: Explicitly define how Ps/Pe and BidiMirroring
   characters match, and resolve the one-to-many
   open/closing mapping by preferring the lower
   codepoint.

Modified: doc/trunk/design/syn/S02.pod
==
--- doc/trunk/design/syn/S02.pod(original)
+++ doc/trunk/design/syn/S02.podWed Apr 26 09:36:05 2006
@@ -51,9 +51,17 @@
 For some syntactic purposes, Perl distinguishes bracketing characters
 from non-bracketing.  Bracketing characters are defined as any Unicode
 characters with either bidirectional mirrorings or Ps/Pe properties.
-(In practice, though, you're safest using matching characters with
+However, bidirectional mirroring characters with no corresponding
+closing characters does not qualify as opening brackets.
+
+In practice, though, you're safest using matching characters with
 Ps/Pe properties, though ASCII angle brackets are a notable exception,
-since they're bidirectional but not in the Ps/Pe set.)
+since they're bidirectional but not in the Ps/Pe set.
+
+The C has two closing alternatives, C and C;
+Perl 6 only recognizes the one with lower code point number, C,
+as the closing brace.  This policy also applies to new one-to-many
+mappings introduced in the future.
 
 =back
 


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

2006-04-26 Thread autrijus
Author: autrijus
Date: Wed Apr 26 09:45:43 2006
New Revision: 8958

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

Log:
* U+201A and U+201E also have to go.

Modified: doc/trunk/design/syn/S02.pod
==
--- doc/trunk/design/syn/S02.pod(original)
+++ doc/trunk/design/syn/S02.podWed Apr 26 09:45:43 2006
@@ -51,18 +51,20 @@
 For some syntactic purposes, Perl distinguishes bracketing characters
 from non-bracketing.  Bracketing characters are defined as any Unicode
 characters with either bidirectional mirrorings or Ps/Pe properties.
-However, bidirectional mirroring characters with no corresponding
-closing characters does not qualify as opening brackets.
 
-In practice, though, you're safest using matching characters with
-Ps/Pe properties, though ASCII angle brackets are a notable exception,
-since they're bidirectional but not in the Ps/Pe set.
+Characters with no corresponding closing characters does not qualify
+as opening brackets.  This includes the second section of the BidiMirroring
+data table, as well as C and C.
 
 The C has two closing alternatives, C and C;
 Perl 6 only recognizes the one with lower code point number, C,
 as the closing brace.  This policy also applies to new one-to-many
 mappings introduced in the future.
 
+In practice, though, you're safest using matching characters with
+Ps/Pe properties, though ASCII angle brackets are a notable exception,
+since they're bidirectional but not in the Ps/Pe set.
+
 =back
 
 =head1 Molecules


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

2006-04-26 Thread autrijus
Author: autrijus
Date: Wed Apr 26 10:05:19 2006
New Revision: 8961

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

Log:
* Further note that Ps/Pe dominates BidiMirroring, so U+298D
  maps to U+298E, and U+298E itself does not open brackets.

Modified: doc/trunk/design/syn/S02.pod
==
--- doc/trunk/design/syn/S02.pod(original)
+++ doc/trunk/design/syn/S02.podWed Apr 26 10:05:19 2006
@@ -52,19 +52,23 @@
 from non-bracketing.  Bracketing characters are defined as any Unicode
 characters with either bidirectional mirrorings or Ps/Pe properties.
 
+In practice, though, you're safest using matching characters with
+Ps/Pe properties, though ASCII angle brackets are a notable exception,
+since they're bidirectional but not in the Ps/Pe set.
+
 Characters with no corresponding closing characters does not qualify
 as opening brackets.  This includes the second section of the BidiMirroring
 data table, as well as C and C.
 
+If a character is already used in Ps/Pe mappings, then its entry in
+BidiMirroring is ignored.  Therefore C maps to C,
+not C, and C itself is not a valid bracket opener.
+
 The C has two closing alternatives, C and C;
 Perl 6 only recognizes the one with lower code point number, C,
 as the closing brace.  This policy also applies to new one-to-many
 mappings introduced in the future.
 
-In practice, though, you're safest using matching characters with
-Ps/Pe properties, though ASCII angle brackets are a notable exception,
-since they're bidirectional but not in the Ps/Pe set.
-
 =back
 
 =head1 Molecules


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

2006-04-26 Thread autrijus
Author: autrijus
Date: Wed Apr 26 10:07:38 2006
New Revision: 8962

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

Log:
* S02: bump version from the unicode change; also merge in
   azuroth++'s typo fix, as well as paragraph reflow.

Modified: doc/trunk/design/syn/S02.pod
==
--- doc/trunk/design/syn/S02.pod(original)
+++ doc/trunk/design/syn/S02.podWed Apr 26 10:07:38 2006
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall <[EMAIL PROTECTED]>
   Date: 10 Aug 2004
-  Last Modified: 25 Apr 2006
+  Last Modified: 26 Apr 2006
   Number: 2
-  Version: 33
+  Version: 34
 
 This document summarizes Apocalypse 2, which covers small-scale
 lexical items and typological issues.  (These Synopses also contain
@@ -1591,18 +1591,19 @@
 the syntax to be inconsistent with that, it is an error of the
 inconsistent signature variety.
 
-If the unrecogized subname is followed by C<< postcircumfix:<( )> >>, it is
-compiled as a provisional function call of the parenthesized form.
+If the unrecognized subroutine name is followed by C<< postcircumfix:<( )> >>,
+it is compiled as a provisional function call of the parenthesized form.
 If it is not, it is compiled as a provisional function call of
 the list operator form, which may or may not have an argument list.
 When in doubt, the attempt is made to parse an argument list.  As with
 any list operator, an immediate postfix operator means there are no
 arguments, whereas anything following whitespace will be interpreted
-as an argument list if possible.  It is illegal for a provisional
-subroutine call to be followed by a colon postfix, since such a colon
-is allowed only on an indirect object or a method call in dot form.
-(It is also allowed on a label when a statement is expected.)
-So for any undeclared identifier "C":
+as an argument list if possible.
+
+It is illegal for a provisional subroutine call to be followed by a
+colon postfix, since such a colon is allowed only on an indirect object,
+or a method call in dot form.  (It is also allowed on a label when a
+statement is expected.) So for any undeclared identifier "C":
 
 foo.bar# foo().bar -- postfix prevents args
 foo .bar   # foo($_.bar)   -- no postfix starts with whitespace
@@ -1636,12 +1637,13 @@
 The indirect object colon only ever dominates a simple term, where
 "simple" includes classes and variables and parenthesized expressions,
 but explicitly not method calls, because the colon will bind to a
-trailing method call in preference.  An indirect object that parses
-as more than one token must be placed in parentheses, followed by
-the colon.  In short, only an identifier followed by a simple term
-followed by a postfix colon is C parsed as an indirect object,
-but that form will C be parsed as an indirect object regardless
-of whether the identifier is otherwise declared.
+trailing method call in preference.  An indirect object that parses as
+more than one token must be placed in parentheses, followed by the colon.
+
+In short, only an identifier followed by a simple term followed by a
+postfix colon is C parsed as an indirect object, but that form
+will C be parsed as an indirect object regardless of whether
+the identifier is otherwise declared.
 
 =item *
 


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

2006-04-26 Thread larry
Author: larry
Date: Wed Apr 26 14:41:21 2006
New Revision: 8967

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

Log:
Typos, clarifications.


Modified: doc/trunk/design/syn/S02.pod
==
--- doc/trunk/design/syn/S02.pod(original)
+++ doc/trunk/design/syn/S02.podWed Apr 26 14:41:21 2006
@@ -56,7 +56,7 @@
 Ps/Pe properties, though ASCII angle brackets are a notable exception,
 since they're bidirectional but not in the Ps/Pe set.
 
-Characters with no corresponding closing characters does not qualify
+Characters with no corresponding closing character do not qualify
 as opening brackets.  This includes the second section of the BidiMirroring
 data table, as well as C and C.
 

Modified: doc/trunk/design/syn/S03.pod
==
--- doc/trunk/design/syn/S03.pod(original)
+++ doc/trunk/design/syn/S03.podWed Apr 26 14:41:21 2006
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall <[EMAIL PROTECTED]>
   Date: 8 Mar 2004
-  Last Modified: 25 Apr 2006
+  Last Modified: 26 Apr 2006
   Number: 3
-  Version: 23
+  Version: 24
 
 =head1 Changes to existing operators
 
@@ -99,9 +99,21 @@
 loop ($a = 1, $b = 2; ; $a++, $b++) {...}
 
 still works fine.  The distinction between scalar and list assignment
-is pretty much identical to the way Perl 5 does it.  If there are
-parens around the left side, or if the sigil of the variable is C<@>
-or C<%>, it's a list assignment.  Otherwise it's a scalar assignment.
+is similar to the way Perl 5 does it.  If there are parens around
+the left side, or if the variable is an array or hash, it's a list
+assignment.  Otherwise it's a scalar assignment.  One difference from
+Perl 5 is that Perl 6 does not attempt to intuit whether an lvalue
+slice is meant to be one element or several, so you must use parens
+in that case.  This is true even if you put something that is obviously
+a list as the subscript:
+
+@x[1,2,3] = 4,5,6; # WRONG
+(@x[1,2,3]) = 4,5,6;   # correct
+
+These parens actually apply list context on both sides:
+
+@x[foo()] = bar(); # foo() and bar() both in scalar context
+(@x[foo()]) = bar();   # foo() and bar() both in list context
 
 =back
 
@@ -719,6 +731,25 @@
 
 $hacker.feed: 'Pizza and cola';
 
+This colon is a separate token.  A colon prefixing an adverb is not
+a separate token.  Therefore, under the longest-token rule,
+
+$hacker.feed:xxx('Pizza and cola');
+
+is tokenized as an adverb applying to the method:
+
+$hacker.feed :xxx('Pizza and cola');
+
+not as an xxx sub in the argument list of .feed:
+
+$hacker.feed: xxx('Pizza and cola');  # wrong
+
+If you want both meanings of colon, you have to put it twice:
+
+$hacker.feed: :xxx('Pizza and cola'), 1,2,3;
+
+(For similar reasons it's best to put whitespace after the colon of a label.)
+
 =head1 C
 
 In order to support parallel iteration over multiple arrays, Perl 6 has
@@ -782,12 +813,12 @@
 method postfix  . .+ .? .* .() .[] .{} .«» .=
 autoincrement   ++ --
 exponentiation  **
-symbolic unary  ! + - ~ ? $ @ % & * ** +^ ~^ ?^ \ ^ = -e -r -w -x etc.
+symbolic unary  ! + - ~ ? $ @ % & * ** +^ ~^ ?^ \ ^ =
 multiplicative  * / % x xx +& +< +> ~& ~< ~>
 additive+ - ~ +| +^ ~| ~^
 junctive and (all)  &
 junctive or (any)   | ^
-named unary rand sleep abs etc.
+named unary rand sleep abs etc. -e -r -w -x etc.
 nonchaining binary  but does cmp <=> .. ^.. ..^ ^..^ ff ^ff ff^ ^ff^ fff 
^fff etc.
 chaining binary != == < <= > >= ~~ !~ eq ne lt le gt ge =:= ===
 tight and   &&