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

2006-09-13 Thread Darren Duncan

At 11:07 AM -0700 9/12/06, [EMAIL PROTECTED] wrote:

+=head1 Cross operators
+
+The final metaoperator is the CX metaoperator.  It applies the
+modified operator across all permutations of its list arguments.  All
+CX operators are of list infix precedence, and are list associative.


AT LAST!

I remember raising the want of such an operator 
on this list a year ago, but nothing really came 
out of it.  Specifically I mean the thread 
crossing lists that I posted on 2005 Oct 27:


http://www.nntp.perl.org/group/perl.perl6.language/23878

But now I can update, for example, ext/Locale-KeyedText/ from this:

  method get_set_member_combinations of Array of Str () {
  return [EMAIL PROTECTED]:{ @!set_names »~« $_ }];
  }

To this:

  method get_set_member_combinations of Array of Str () {
  return [EMAIL PROTECTED] X~ @!member_names];
  }

So the code is now much more understandable as to what it does.

It should also help me to implement some aspects of Set::Relation, maybe.

Thank you for this update.

-- Darren Duncan


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

2006-09-13 Thread Miroslav Silovic

[EMAIL PROTECTED] wrote:


+=head1 Cross operators
+
+The final metaoperator is the CX metaoperator.  It applies the
+modified operator across all permutations of its list arguments.  All
+CX operators are of list infix precedence, and are list associative.
+
+The bare form of CX is considered an operator in its own right.
+Saying:
+
+a b X 1,2 X x y
+
+produces
+
+['a', 1, 'x'],
+['a', 1, 'y'],
+['a', 2, 'x'],
+['a', 2, 'y'],
+['b', 1, 'x'],
+['b', 1, 'y'],
+['b', 2, 'x'],
+['b', 2, 'y']



Would it be possible to extend Cnext to pass its arguments to the 
iterator being 'nexted'. Along with proper arguments to whichever lazy 
object it generated by X, it'd enable this:


(where :$slice argument would cause X to increment the member of the 
tuple at the appropriate index, and resets all the other ones):


for 1,2,3 X 1,2,3 - [$i, $j] {
   if $j  $i { next(slice = 0); }
   say $i, $j;
}

11
21
22
31
32
33

As another example, if a tree iterator has :right keyword argument to 
return the node to the right, you could do:


for $tree.each - $node {
   if $node.value  $goal { next; }
   if $node.value  $goal {next :right; }
   return $node;
}

Alternative proposal could be to allow expression after next, which gets 
evaluated instead of incrementing the iterator, iterator is topic in 
that expression and is replaced by the result.


So next True; causes infinite loop, next .left calls .left accessor and 
next .right calls right accessor before reentering loop (but doesn't do 
the default increment that for does).







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

2006-09-13 Thread Daniel Hulme
 svn log, speaking on larry's behalf ():
  +The string concatenating form is:
  +
  +a b X~X 1 2   #  'a1', 'a2', 'b1', 'b2'
  +
  +The CX~X operator desugars to something like:
  +
  +[~]�( a b X 1 2 )  #  'a1', 'a2', 'b1', 'b2'
 ^

 If the CX variant already concatenates strings, why is it done
 explicitly in the desugaring of CX~X? Probably not what you
 intended.

I think it's just that the change is incomplete. It looks like the X
I've marked should have been changed to a XX.

-- 
Of all  things,  good sense is  the most fairly  distributed:  everyone
thinks  he is  so well  supplied  with it  that even  those who  are the
hardest to satisfy in  every other respect never  desire more of it than
they already have.   --  Descartes, 1637  http://surreal.istic.org/


pgpjILcxxtBjT.pgp
Description: PGP signature


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

2006-09-13 Thread Carl Mäsak

Daniel (), Carl (), svn log, speaking on larry's behalf ():

  +The string concatenating form is:
  +
  +a b X~X 1 2   #  'a1', 'a2', 'b1', 'b2'
  +
  +The CX~X operator desugars to something like:
  +
  +[~]�( a b X 1 2 )  #  'a1', 'a2', 'b1', 'b2'
 ^

 If the CX variant already concatenates strings, why is it done
 explicitly in the desugaring of CX~X? Probably not what you
 intended.

I think it's just that the change is incomplete. It looks like the X
I've marked should have been changed to a XX.


Yes, I suspected so too, though I wasn't sure so I didn't write it. :)

Even better, it could be changed into CX,X, unnecessitating another
desugaring (mental or parse-al).

// Carl


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

2006-09-13 Thread larry
Author: larry
Date: Wed Sep 13 07:03:51 2006
New Revision: 11976

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

Log:
typo spotted by Carl Mäsak++


Modified: doc/trunk/design/syn/S03.pod
==
--- doc/trunk/design/syn/S03.pod(original)
+++ doc/trunk/design/syn/S03.podWed Sep 13 07:03:51 2006
@@ -14,7 +14,7 @@
   Date: 8 Mar 2004
   Last Modified: 13 Sep 2006
   Number: 3
-  Version: 61
+  Version: 62
 
 =head1 Changes to Perl 5 operators
 
@@ -1042,9 +1042,9 @@
 
 The CX~X operator desugars to something like:
 
-[~]«( a b X 1 2 )  #  'a1', 'a2', 'b1', 'b2'
+[~]«( a b X,X 1 2 )  #  'a1', 'a2', 'b1', 'b2'
 
-The list concatenating form
+The list concatenating form, CX,X, when used like this:
 
 a b X,X 1,2 X,X x y
 
@@ -1082,6 +1082,8 @@
 Note that only the first term of an CX operator may reasonably be
 an infinite list.
 
+Multidimensional lists should be handled properly.
+
 =head1 Junctive operators
 
 C|, C, and C^ are no longer bitwise operators (see


Re: Unpacking tree node parameters

2006-09-13 Thread Audrey Tang


在 Sep 4, 2006 2:11 AM 時,Gaal Yahas 寫到:

Unless I'm mistaken, this doesn't cast back to subroutine signature  
land

very well:

  sub f1 (Dog ($fido, $spot))   { ... }
  sub f2 (Dog $ ($fido, $spot)) { ... }
  sub f3 (Dog :($fido, $spot))  { ... }


Correct.


Unless Audrey's latest S03 patch pertains here as well, and Dog
distributes; in that case it would be as if the programmer had written

  sub f1 ([Dog $fido, Dog $spot])   { ... }


Yes, except there's no [] there; it's two positional parameters.

as described in the preceding section, Unpacking array  
parameters. If

this is *not* the case, then f1 is not ambiguous!


TimToady++ just confirmed on IRC that it is indeed the case.

Please clarify, so I can clean up the confusing paragraph and  
introduce

the optionality of the colon less jarringly.


Woot! :-)

Audrey



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

2006-09-13 Thread larry
Author: larry
Date: Wed Sep 13 11:05:34 2006
New Revision: 11977

Modified:
   doc/trunk/design/syn/S02.pod
   doc/trunk/design/syn/S03.pod
   doc/trunk/design/syn/S06.pod
   doc/trunk/design/syn/S09.pod
   doc/trunk/design/syn/S12.pod

Log:
Metamethod revamp.


Modified: doc/trunk/design/syn/S02.pod
==
--- doc/trunk/design/syn/S02.pod(original)
+++ doc/trunk/design/syn/S02.podWed Sep 13 11:05:34 2006
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall [EMAIL PROTECTED]
   Date: 10 Aug 2004
-  Last Modified: 27 Aug 2006
+  Last Modified: 13 Sept 2006
   Number: 2
-  Version: 66
+  Version: 67
 
 This document summarizes Apocalypse 2, which covers small-scale
 lexical items and typological issues.  (These Synopses also contain
@@ -455,13 +455,11 @@
 can speed it up.)
 
 Some object types can behave as value types.  Every object can produce
-a safe key identifier (CSKID for short) that uniquely identifies the
+a WHICH value that uniquely identifies the
 object for hashing and other value-based comparisons.  Normal objects
 just use their address in memory, but if a class wishes to behave as a
-value type, it can define a C.SKID method that makes different objects
+value type, it can define a C.WHICH method that makes different objects
 look like the same object if they happen to have the same contents.
-SKID may also stand for static key id, or silly key id, or
-secret key id, or supercalifragilisticexpialidocious key id.
 
 =item *
 
@@ -483,13 +481,13 @@
 
 =item *
 
-Every object supports a CMETA function/method that returns the
+Every object supports a CHOW function/method that returns the
 metaclass instance managing it, regardless of whether the object
 is defined:
 
-'x'.META.get_method_list;   # get available methods for strings
-Str.META.get_method_list;   # same thing with the prototype object Str
-META(Str).get_method_list;  # same thing as function call
+'x'.HOW.get_method_list;   # get available methods for strings
+Str.HOW.get_method_list;   # same thing with the prototype object Str
+HOW(Str).get_method_list;  # same thing as function call
 
 'x'.get_method_list;# this is an error - not a meta object
 Str.get_method_list;# same thing

Modified: doc/trunk/design/syn/S03.pod
==
--- doc/trunk/design/syn/S03.pod(original)
+++ doc/trunk/design/syn/S03.podWed Sep 13 11:05:34 2006
@@ -14,7 +14,7 @@
   Date: 8 Mar 2004
   Last Modified: 13 Sep 2006
   Number: 3
-  Version: 62
+  Version: 63
 
 =head1 Changes to Perl 5 operators
 
@@ -373,7 +373,7 @@
 CArray objects, but it is true that C@a === @a because those are
 the same CArray object).
 
-Any object type may pretend to be a value type by defining a C.SKID
+Any object type may pretend to be a value type by defining a C.WHICH
 method which returns a value type that can be recursively compared
 using C===, or in cases where that is impractical, by overloading
 C=== such that the comparison treats values consistently with their
@@ -494,7 +494,7 @@
 for ^(3,3) { ... } # (0,0)(0,1)(0,2)(1,0)(1,1)(1,2)(2,0)(2,1)(2,2)
 
 If applied to a type name, it indicates the metaclass instance instead,
-so C^Moose is short for CMETA(Moose) or CMoose.META.  It still kinda
+so C^Moose is short for CHOW(Moose) or CMoose.HOW.  It still kinda
 means what is this thing's domain in an abstract sort of way.
 
 =item * The C... operator is the yada, yada, yada list operator,
@@ -512,7 +512,7 @@
 variants C.*, C.?, and C.+ to control how multiple related methods
 of the same name are handled.  The C.= operator does inplace modification
 of the object on the left.  The C.^ operator calls a class metamethod;
-Cfoo.^bar is short for Cfoo.META.bar.
+Cfoo.^bar is short for Cfoo.HOW.bar.
 
 =item * Unary C= reads lines from a filehandle or filename, or
 iterates an iterator, or in general causes a scalar to explode its guts

Modified: doc/trunk/design/syn/S06.pod
==
--- doc/trunk/design/syn/S06.pod(original)
+++ doc/trunk/design/syn/S06.podWed Sep 13 11:05:34 2006
@@ -13,9 +13,9 @@
 
   Maintainer: Larry Wall [EMAIL PROTECTED]
   Date: 21 Mar 2003
-  Last Modified: 25 Aug 2006
+  Last Modified: 13 Sept 2006
   Number: 6
-  Version: 53
+  Version: 54
 
 
 This document summarizes Apocalypse 6, which covers subroutines and the
@@ -1358,7 +1358,7 @@
 
 Objects with these types behave like values, i.e. C$x === $y is true
 if and only if their types and contents are identical (that is, if
-C$x.SKID eqv C$y.SKID).
+C$x.WHICH eqv C$y.WHICH).
 
 Bit Perl single bit (allows traits, aliasing, undef, etc.)
 Int Perl integer (allows Inf/NaN, arbitrary precision, etc.)
@@ -1382,7 +1382,7 @@
 
 =head2 Mutable types
 
-Objects with these types have 

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

2006-09-13 Thread Darren Duncan

At 11:05 AM -0700 9/13/06, [EMAIL PROTECTED] wrote:

Modified: doc/trunk/design/syn/S02.pod
+'x'.HOW.get_method_list;   # get available methods for strings

snip

Modified: doc/trunk/design/syn/S12.pod
+The C.HOW.getmethods method returns method-descriptors containing:


As you can see, there is a repeated inconsistency here as to the name 
of this meta-object method.  While it is possible that the actual 
meta-object API hasn't been decided on yet, the stand-in Synopsis 
examples should at least be consistent. -- Darren Duncan


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

2006-09-13 Thread larry
Author: larry
Date: Wed Sep 13 15:20:27 2006
New Revision: 11978

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

Log:
Clarified that interogative methods are also named unaries.


Modified: doc/trunk/design/syn/S12.pod
==
--- doc/trunk/design/syn/S12.pod(original)
+++ doc/trunk/design/syn/S12.podWed Sep 13 15:20:27 2006
@@ -14,7 +14,7 @@
   Date: 27 Oct 2004
   Last Modified: 13 Sept 2006
   Number: 12
-  Version: 22
+  Version: 23
 
 =head1 Overview
 
@@ -1506,6 +1506,12 @@
 WHEN   (reserved for events?)
 WHY(reserved for documentation?)
 
+None of these methods takes arguments, so they may also be used as
+named unary operators:
+
+$obj.WHAT   # method form of P5's ref
+WHAT $obj   # unary form of P5's ref
+
 In general, use of these in ordinary code should be a red flag that
 Something Very Strange is going on.  (Hence the allcaps.)  Most code
 should use Perl 6's operators that make use of this information


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

2006-09-13 Thread larry
Author: larry
Date: Wed Sep 13 17:36:38 2006
New Revision: 11979

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

Log:
regularized metaobject method names as requested by dduncan++


Modified: doc/trunk/design/syn/S02.pod
==
--- doc/trunk/design/syn/S02.pod(original)
+++ doc/trunk/design/syn/S02.podWed Sep 13 17:36:38 2006
@@ -14,7 +14,7 @@
   Date: 10 Aug 2004
   Last Modified: 13 Sept 2006
   Number: 2
-  Version: 67
+  Version: 68
 
 This document summarizes Apocalypse 2, which covers small-scale
 lexical items and typological issues.  (These Synopses also contain
@@ -485,12 +485,12 @@
 metaclass instance managing it, regardless of whether the object
 is defined:
 
-'x'.HOW.get_method_list;   # get available methods for strings
-Str.HOW.get_method_list;   # same thing with the prototype object Str
-HOW(Str).get_method_list;  # same thing as function call
+'x'.HOW.methods;   # get available methods for strings
+Str.HOW.methods;   # same thing with the prototype object Str
+HOW(Str).methods;  # same thing as function call
 
-'x'.get_method_list;# this is an error - not a meta object
-Str.get_method_list;# same thing
+'x'.methods;# this is likely an error - not a meta object
+Str.methods;# same thing
 
 (For a prototype system (a non-class-based object system), all objects are 
merely managed by the same meta object.)
 

Modified: doc/trunk/design/syn/S12.pod
==
--- doc/trunk/design/syn/S12.pod(original)
+++ doc/trunk/design/syn/S12.podWed Sep 13 17:36:38 2006
@@ -14,7 +14,7 @@
   Date: 27 Oct 2004
   Last Modified: 13 Sept 2006
   Number: 12
-  Version: 23
+  Version: 24
 
 =head1 Overview
 
@@ -1532,19 +1532,19 @@
 for the class (or other metaobject protocol) implementing the objects
 of the class:
 
-MyClass.getmethods()   # call MyClass's .getmethods method (error?)
-MyClass.HOW.getmethods()   # get the method list of MyClass
+MyClass.methods()  # call MyClass's .methods method (error?)
+MyClass.HOW.methods()  # get the method list of MyClass
 
-The C^ metasyntax is equivalent to .HOW:
+The C^ metasyntax is equivalent to C.HOW:
 
-MyClass.HOW.getmethods()   # get the method list of MyClass
-^MyClass.getmethods()  # get the method list of MyClass
-MyClass.^getmethods()  # get the method list of MyClass
+MyClass.HOW.methods()  # get the method list of MyClass
+^MyClass.methods() # get the method list of MyClass
+MyClass.^methods() # get the method list of MyClass
 
 Each object of the class also has a C.HOW or C.^ method:
 
-$obj.HOW.getmethods();
-$obj.^getmethods();
+$obj.HOW.methods();
+$obj.^methods();
 
 Class traits may include:
 
@@ -1572,7 +1572,7 @@
 prototype objects, in which case stringification is not likely to
 produce something of interest to non-gurus.)
 
-The C.HOW.getmethods method returns method-descriptors containing:
+The C.HOW.methods method returns method-descriptors containing:
 
 name   the name of the method
 signature  the parameters of the method
@@ -1580,11 +1580,11 @@
 multi  whether duplicate names are allowed
 do the method body
 
-The C.getmethods method has a selector parameter that lets you
+The C.methods method has a selector parameter that lets you
 specify whether you want to see a flattened or hierarchical view,
 whether you're interested in private methods, and so forth.
 
-The C.getattributes method returns a list of attribute descriptors
+The C.attributes method returns a list of attribute descriptors
 that have traits like these:
 
 name
@@ -1603,7 +1603,23 @@
 $obj.HOW.does(Dog)
 $obj.HOW.isa(Mammal)
 
-But CObject gives you shortcuts to those, if you don't override them.
+or
+
+$obj.^can(bark)
+$obj.^does(Dog)
+$obj.^isa(Mammal)
+
+But CAny gives you shortcuts to those:
+
+$obj.can(bark)
+$obj.does(Dog)
+$obj.isa(Mammal)
+
+These, may, of course, be overridden in a subclass, so don't use the
+short form unless you wish to allow for overrides.  In general, CAny
+will delegate only those metamethods that read well when reasoning
+about an individual object.  Infrastructural methods like C.methods
+and C.attributes are not delegated, so C$obj.methods fails.
 
 The smartmatch: