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

2006-11-30 Thread TSa

HaloO,

[EMAIL PROTECTED] wrote:

$_  $xType of Match ImpliedMatching Code
==  = ==
+   Set Set   members identicalmatch if $_ === $x

 +   Array   Set   array equivalent to set  match if Set($_) === $x

Isn't it better to define these in terms of Bags? I mean with
Bag a supertype of Set the dispatch should go to cases 
infix===:(Bag,Bag), infix===:(Bag,Set), infix===:(Set,Bag)

and infix===:(Set,Set).

Regards, TSa.
--


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

2006-11-30 Thread Larry Wall
On Thu, Nov 30, 2006 at 09:43:40AM +0100, TSa wrote:
: HaloO,
: 
: [EMAIL PROTECTED] wrote:
: $_  $xType of Match ImpliedMatching Code
: ==  = ==
: +   Set Set   members identicalmatch if $_ === $x
:  +   Array   Set   array equivalent to set  match if Set($_) === $x
: 
: Isn't it better to define these in terms of Bags? I mean with
: Bag a supertype of Set the dispatch should go to cases 
: infix===:(Bag,Bag), infix===:(Bag,Set), infix===:(Set,Bag)
: and infix===:(Set,Set).

I think that most Perl programmers would rather view Sets and Bags through
the Hash lens, so I think I'm going to try to avoid mentioning Sets and Bags
in the smartmatching table entirely, and only differentiate KeyHash, if
we differentiate anything.  In this view all of Set, Bag, KeySet and KeyBag
are really KeyHash, which is a Hash that is being used primarily for its
keys.  Set and Bag just happen to be constant values of KeySet and KeyBag
that also happen to override === and .WHICH to provide value rather
than object semantics.

I think a consequence of this view is that (x) ops are all key-based set
ops unless you explicitly make sure both sides are bags.  But it's still
early enough in the morning that I've not thought this through entirely...

What I do know this early is that we can't turn the hardwired
smartmatch table into a complete crossbar of every type combination
we can think up now and in the future.  For learnability we've got
to keep it linear somehow.  That's my main motivation for trying to
smash Set and Bag into being variants of the Hash role.

Larry


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

2006-11-29 Thread larry
Author: larry
Date: Wed Nov 29 09:20:50 2006
New Revision: 13487

Modified:
   doc/trunk/design/syn/S01.pod
   doc/trunk/design/syn/S02.pod
   doc/trunk/design/syn/S03.pod
   doc/trunk/design/syn/S04.pod
   doc/trunk/design/syn/S05.pod
   doc/trunk/design/syn/S06.pod
   doc/trunk/design/syn/S09.pod
   doc/trunk/design/syn/S10.pod
   doc/trunk/design/syn/S11.pod
   doc/trunk/design/syn/S12.pod
   doc/trunk/design/syn/S13.pod
   doc/trunk/design/syn/S17.pod
   doc/trunk/design/syn/S29.pod

Log:
More entries in smartmatch table.
Added vim modelines to help perpetuate audreyt++'s expandtabs.


Modified: doc/trunk/design/syn/S01.pod
==
--- doc/trunk/design/syn/S01.pod(original)
+++ doc/trunk/design/syn/S01.podWed Nov 29 09:20:50 2006
@@ -161,3 +161,5 @@
 into a coherent whole.
 
 =back
+
+=for vim:set expandtab sw=4:

Modified: doc/trunk/design/syn/S02.pod
==
--- doc/trunk/design/syn/S02.pod(original)
+++ doc/trunk/design/syn/S02.podWed Nov 29 09:20:50 2006
@@ -2420,3 +2420,5 @@
 
 Any category containing circumfix requires two token arguments, supplied
 in slice notation.
+
+=for vim:set expandtab sw=4:

Modified: doc/trunk/design/syn/S03.pod
==
--- doc/trunk/design/syn/S03.pod(original)
+++ doc/trunk/design/syn/S03.podWed Nov 29 09:20:50 2006
@@ -14,7 +14,7 @@
   Date: 8 Mar 2004
   Last Modified: 13 Nov 2006
   Number: 3
-  Version: 75
+  Version: 76
 
 =head1 Changes to Perl 5 operators
 
@@ -582,8 +582,10 @@
 $_  $xType of Match ImpliedMatching Code
 ==  = ==
 Any Code:($)  scalar sub truth match if $x($_)
-HashHash  hash keys identical  match if $_.keys.sort »eq« 
$x.keys.sort
-Hashany(Hash) hash key intersectionmatch if $_{any(Hash.keys)}
+HashHash  hash keys identical  match if $_.keys === $x.keys
+HashSet   members identicalmatch if $_.keys === $x
+Set Set   members identicalmatch if $_ === $x
+Hashany(Hash) hash key intersectionmatch if exists 
$_{any(Hash.keys)}
 HashArray hash value slice truth   match if $_{any(@$x)}
 Hashany(list) hash key slice existence match if exists $_{any(list)}
 Hashall(list) hash key slice existence match if exists $_{all(list)}
@@ -596,9 +598,13 @@
 Array   Regex array grep   match if any(@$_) ~~ /$x/
 Array   Num   array contains numbermatch if any($_) == $x
 Array   Str   array contains stringmatch if any($_) eq $x
+Array   Buf   array equivalent to buf  match if $_ eqv Array($x)
+Array   Set   array equivalent to set  match if Set($_) === $x
+Array   Any   array contains item* match if any($_) === $x
 Array   .[number] array element truth* match if $_[number]
 Num NumRange  in numeric range match if $min = $_ = $max
 Str StrRange  in string range  match if $min le $_ le $max
+Any Range in range match if $min !after $_ !after 
$max
 Capture Signature parameter bindingmatch if $cap can bind to $sig
 CodeSignature signature compatibility* match if $_ is a subset of $x
   Signature Signature signature compatibility  match if $_ is a subset of $x
@@ -1699,3 +1705,4 @@
 Comma is the only listop that is allowed to occur where an operator is
 expected.  All other listops function as a term within the list to the left.
 
+=for vim:set expandtab sw=4:

Modified: doc/trunk/design/syn/S04.pod
==
--- doc/trunk/design/syn/S04.pod(original)
+++ doc/trunk/design/syn/S04.podWed Nov 29 09:20:50 2006
@@ -985,3 +985,5 @@
 to see transient variables in their current lexical scope, so their
 cloning status depends at least on the cloning status of the block
 they're in.
+
+=for vim:set expandtab sw=4:

Modified: doc/trunk/design/syn/S05.pod
==
--- doc/trunk/design/syn/S05.pod(original)
+++ doc/trunk/design/syn/S05.podWed Nov 29 09:20:50 2006
@@ -3071,3 +3071,5 @@
  @array».match($regex);
 
 =back
+
+=for vim:set expandtab sw=4:

Modified: doc/trunk/design/syn/S06.pod
==
--- doc/trunk/design/syn/S06.pod(original)
+++ doc/trunk/design/syn/S06.podWed Nov 29 09:20:50 2006
@@ -2653,3 +2653,5 @@
 If a switch of the form C-abc cannot be matched against any
 particular parameter, an attempt will be made to match it as if it
 had been written C-a -b -c.
+
+=for vim:set expandtab sw=4:


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

2006-11-29 Thread Smylers
[EMAIL PROTECTED] writes:

 Log:
 More entries in smartmatch table.
 
 +++ doc/trunk/design/syn/S03.pod  Wed Nov 29 09:20:50 2006
 +HashHash  hash keys identical  match if $_.keys === $x.keys
 +HashSet   members identicalmatch if $_.keys === $x
 +Set Set   members identicalmatch if $_ === $x
 +Hashany(Hash) hash key intersectionmatch if exists 
 $_{any(Hash.keys)}

Should that last one have a C$x in the code somewhere?

Smylers