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

2006-07-15 Thread larry
Author: larry
Date: Sat Jul 15 00:15:51 2006
New Revision: 10217

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

Log:
More clarifications, many suggested by dduncan++.


Modified: doc/trunk/design/syn/S03.pod
==
--- doc/trunk/design/syn/S03.pod(original)
+++ doc/trunk/design/syn/S03.podSat Jul 15 00:15:51 2006
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall <[EMAIL PROTECTED]>
   Date: 8 Mar 2004
-  Last Modified: 14 Jul 2006
+  Last Modified: 15 Jul 2006
   Number: 3
-  Version: 47
+  Version: 48
 
 =head1 Changes to existing operators
 
@@ -29,7 +29,8 @@
 =item * C<< -> >> becomes C<.>, like the rest of the world uses.
 
 =item * The string concatenation C<.> becomes C<~>.  Think of it as
-"stitching" the two ends of its arguments together.
+"stitching" the two ends of its arguments together.  String append
+is likewise C<~=>.
 
 =item * All postfix operators that do not start with a dot also have
 an alternate form that does.  (The converse does not hold--just because
@@ -50,17 +51,31 @@
 so you need C<$($foo[bar])> to mean the other way.
 
 =item * Bitwise operators get a data type prefix: C<+>, C<~>, or C.
-For example, C<|> becomes either C<+|> or C<~|> or C, depending on
-whether the operands are to be treated as numbers, strings, or boolean
-values.  Left shift C< << > becomes C< +< >, and correspondingly with
-right shift. Unary C<~> becomes either C<+^> or C<~^> or C, since a
-bitwise NOT is like an exclusive-or against solid ones.  Note that C
-is functionally identical to C.  C differs from C<||> in that
-C always returns a standard boolean value (either 1 or 0), whereas
-C<||> return the actual value of the first of its arguments that is
-true.  Bitwise string operators may only be applied to C types or
-similar compact integer arrays, and treat the entire chunk of memory
-as a single huge integer.
+For example, Perl 5's C<|> becomes either C<+|> or C<~|> or C,
+depending on whether the operands are to be treated as numbers,
+strings, or boolean values.  Perl 5's left shift C< << > becomes
+C< +< >, and correspondingly with right shift. Perl 5's unary C<~>
+(one's complement) becomes either C<+^> or C<~^> or C, since a
+bitwise NOT is like an exclusive-or against solid ones.  Note that
+C is functionally identical to C, but conceptually coerces to
+boolean first and then flips the bit.  Please use C instead.
+
+C is a logical OR but differs from C<||> in that C always
+evaluates both sides and returns a standard boolean value.  That is,
+it's equivalent to C<< ?$a + ?$b != 0 >>.  Another difference is that
+it has the precedence of an additive operator.
+
+C is a logical AND but differs from C<&&> in that C always
+evaluates both sides and returns a standard boolean value.  That is,
+it's equivalent to C<< ?$a * ?$b != 0 >>.  Another difference is that
+it has the precedence of a multiplicative operator.
+
+Bitwise string operators (those starting with C<~>) may only be
+applied to C types or similar compact integer arrays, and treat
+the entire chunk of memory as a single huge integer.  They differ from
+the C<+> operators in that the C<+> operators would try to convert
+the string to a number first on the assumption that the string was an
+ASCII representation of a number.
 
 =item * C splits into two operators: C (which concatenates repetitions 
 of a string to produce a single string), and C (which creates a list of 
@@ -108,7 +123,7 @@
 
 ($a,$b,$c) = 1,2,3;
 
-since list assignment operators are of assignment precedence to their left.
+since assignment operators are tighter than comma to their left.
 
 =item * The scalar assignment operator still parses as it did before, so
 
@@ -379,7 +394,8 @@
 in terms of C, so C<$a leg $b> is now defined as C<~$a cmp ~$b>.
 The sort operator still defaults to C rather than C.  The
 C<< <=> >> operator's semantics are unchanged except that it returns
-an C value as described above.
+an C value as described above.  In other words, C<< $a <=> $b >>
+is now equivalent to C<+$a cmp +$b>.
 
 =item * Binary C<< => >> is no longer just a "fancy comma".  It now
 constructs a C object that can, among other things, be used to
@@ -393,8 +409,9 @@
 is much more general now.  See "Smart matching" below for details.  (To catch
 "brainos", the Perl 6 parser defines an C<< infix:<=~> >> macro which always
 fails at compile time with a message directing the user either to use C<~~>
-or C<~=> instead, or to put a space between if they really wanted to assign
-a stringified value.)
+or C<~=> (string append) instead, or to put a space between if they
+really wanted to assign a stringified value.)  A negated smart match is
+spelled C.
 
 =item * "Unary" C<.> calls its single argument (which must a postfix operator)
 on C<$_>.  (It's not really a unary operator, so we put it in quotes.)
@@ -582,11 +599,22 @@
 =head1 Meta operators
 
 Perl 6's operators have been greatly regularized, f

A note for test writers

2006-07-15 Thread Leopold Toetsch
Folks,

Please always verify test results, don't use the Parrot output of the test as 
the expected output.
If you are implementing a new feature, write the *test first*.

Thanks,
leo

PS from r13305:

@@ -1324,7 +1324,7 @@
set P2, 300 # .Integer
set P3, 246.246 # .Float
div P2, P2, P3
-   eq P2, 1, EQ4
+   .fp_eq( P2, 1.218293, EQ4)

300 / 246.246 just isn't 1 exactly


Re: A note for test writers

2006-07-15 Thread jerry gay

On 7/15/06, Leopold Toetsch <[EMAIL PROTECTED]> wrote:

Folks,

Please always verify test results, don't use the Parrot output of the test as
the expected output.
If you are implementing a new feature, write the *test first*.

Thanks,
leo

PS from r13305:

@@ -1324,7 +1324,7 @@
set P2, 300 # .Integer
set P3, 246.246 # .Float
div P2, P2, P3
-   eq P2, 1, EQ4
+   .fp_eq( P2, 1.218293, EQ4)

300 / 246.246 just isn't 1 exactly


i'm pretty sure this was intended for p6i, not p6l, so i'm forwarding it there.
~jerry


binding operators and related introspection

2006-07-15 Thread Darren Duncan
After confirming between Synopsis 3 and the newest Pugs that the 
binding operator := works as follows ...


  my $x = 'foo';
  my $y = 'bar';
  my $z := $x;# $x and $z point to same 'foo', $y to a 'bar'
  $z := $y;   # $y and $z point to the same 'bar', $x to a 'foo'
  print "x,y,z are '$x','$y','$z'\n"; # output: x,y,z are 'foo','bar','bar'

That makes sense of course, and is what people would want most of the time.

But I would also like to have an easy way to change all bindings to 
the same variable at once to point to the same new variable. 
Essentially an easy way for us to implement ourselves the run-time 
folding that I raised in the "optimizing with === immutable 
comparitor" thread.  I would like for this to work:


  my $x = 'foo';
  my $y = 'bar';
  my $z := $x;# $x and $z point to same 'foo', $y to a 'bar'
  $z.rebind_all_aliases_to( $y ); # $x and $y and $z all point to 'bar'

Alternately or in addition to the last line, if something like this could work:

  for $z.aliases -> $z_alias {
$z_alias := $y;
  }
  # now $x and $y and $z all point to 'bar'

Unless something like this could be available for use, it would be 
impractical to implement run time folding just using := since we 
could end up in a tug of war situation if folding comparisons between 
pairs drawn from a pool of all equal elements were not done in 
exactly the right sequence.


-- Darren Duncan