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

2006-04-03 Thread autrijus
Author: autrijus
Date: Mon Apr  3 05:47:07 2006
New Revision: 8553

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

Log:
* S09: Leo pointed out the paragraph on autovivifiction 
  is still mentioning references.  Replace it with modern
  wording (surface semantics stays unchanged)

Modified: doc/trunk/design/syn/S09.pod
==
--- doc/trunk/design/syn/S09.pod(original)
+++ doc/trunk/design/syn/S09.podMon Apr  3 05:47:07 2006
@@ -696,9 +696,10 @@
 my $val := $hash{foo}{bar};
 
 my @array;
-my $ref = \$array[0][0];
+my $ref = \$array[0][0]; # $ref is an Arguments object - see S02
 
 my %hash;
 $hash{foo}{bar} = foo; # duh
 
-This rule applies to dereferencing arrays, hashes, and scalar references.
+This rule applies to CArray, CHash, and CScalar container objects.
+


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

2006-04-03 Thread Amos Robinson
This is perl 6, right?
my %hash; $hash{foo}{bar} - shouldn't it be %hash{foo}{bar}?

On 4/3/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Author: autrijus
 Date: Mon Apr  3 05:47:07 2006
 New Revision: 8553

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

 Log:
 * S09: Leo pointed out the paragraph on autovivifiction
   is still mentioning references.  Replace it with modern
   wording (surface semantics stays unchanged)

 Modified: doc/trunk/design/syn/S09.pod
 ==
 --- doc/trunk/design/syn/S09.pod(original)
 +++ doc/trunk/design/syn/S09.podMon Apr  3 05:47:07 2006
 @@ -696,9 +696,10 @@
  my $val := $hash{foo}{bar};

  my @array;
 -my $ref = \$array[0][0];
 +my $ref = \$array[0][0]; # $ref is an Arguments object - see S02

  my %hash;
  $hash{foo}{bar} = foo; # duh

 -This rule applies to dereferencing arrays, hashes, and scalar references.
 +This rule applies to CArray, CHash, and CScalar container objects.
 +



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

2006-04-03 Thread Luke Palmer
On 4/3/06, Amos Robinson [EMAIL PROTECTED] wrote:
 This is perl 6, right?
 my %hash; $hash{foo}{bar} - shouldn't it be %hash{foo}{bar}?

%hashfoobar even.

Luke


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

2006-04-03 Thread autrijus
Author: autrijus
Date: Mon Apr  3 15:48:30 2006
New Revision: 8555

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

Log:
* S06: Make it clear that concat-means-concat for duplicated
   named arguments, and that it is possible to bind a tuple 
   into a scalar.

sub fun (Int @x) { ... }
fun( x = (1, 2), x = (3, 4) );# @x := (1, 2, 3, 4)

sub fun (Int $x) { ... }
fun( x = (1, 2), x = (3, 4) );# $x := (3, 4)


Modified: doc/trunk/design/syn/S06.pod
==
--- doc/trunk/design/syn/S06.pod(original)
+++ doc/trunk/design/syn/S06.podMon Apr  3 15:48:30 2006
@@ -423,15 +423,17 @@
 to be concatenated:
 
 sub fun (Int @x) { ... }
-fun( x = 1, x = 2 );  # @x := (1, 2)
+fun( x = 1, x = 2 );  # @x := (1, 2)
+fun( x = (1, 2), x = (3, 4) );# @x := (1, 2, 3, 4)
 
 Other sigils binds only to the Ilast argument with that name:
 
 sub fun (Int $x) { ... }
-f( x = 1, x = 2 );# $x := 2
+f( x = 1, x = 2 );# $x := 2
+fun( x = (1, 2), x = (3, 4) );# $x := (3, 4)
 
-This means a defaults must come Ibefore known named parameters,
-similar to how hash constructors work:
+This means a hash holding default values must come Ibefore known named
+parameters, similar to how hash constructors work:
 
 # Allow x and y in %defaults be overrided
 f( *%defaults, x = 1, y = 2 );


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

2006-04-03 Thread larry
Author: larry
Date: Mon Apr  3 15:59:38 2006
New Revision: 8556

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

Log:
Fixed P5isms in P6 code.


Modified: doc/trunk/design/syn/S09.pod
==
--- doc/trunk/design/syn/S09.pod(original)
+++ doc/trunk/design/syn/S09.podMon Apr  3 15:59:38 2006
@@ -688,18 +688,18 @@
 In Perl 6 these read-only operations are indeed non-destructive:
 
 my %hash;
-exists $hash{foo}{bar}; # %hash is still empty
+exists %hashfoobar; # %hash is still empty
 
 But these ones Ido autovivify:
 
 my %hash;
-my $val := $hash{foo}{bar};
+my $val := %hashfoobar;
 
 my @array;
-my $ref = \$array[0][0]; # $ref is an Arguments object - see S02
+my $ref = [EMAIL PROTECTED]; # $ref is an Arguments object - see S02
 
 my %hash;
-$hash{foo}{bar} = foo; # duh
+%hashfoobar = foo; # duh
 
 This rule applies to CArray, CHash, and CScalar container objects.
 


Re: curly-quotes

2006-04-03 Thread Larry Wall
On Sun, Apr 02, 2006 at 02:32:03AM -0800, Jonathan Lang wrote:
: Given perl6's use of unicode as a basis, could we get curly quotes,
: both single and double, to do the same things that straight quotes do?

Depends on what same thing means, I suppose.  Looks like you want
them directional, which is not exactly the same thing.  An argument
could also be made for simply treating them all as the same character.
That being said...

:  That is: text does the same thing as text, and 'text' does the
: same thing as 'text'.  Other than looks neat, why do this?  Because
: curly-quotes come in matching sets, like parentheses and brackets do;
: this lets you nest them.

Hmm, yes.  That would be nice.  But then, any number of bracketing
characters would be nice to steal from non-Latin-1 Unicode, and we're
trying to restrain ourselves for the moment.  Because...

: (This seems so simple and obvious that I'll be surprised if someone
: hasn't already proposed this; however, I don't recall seeing it
: anywhere.)

Either your mailer or some MTA along the way seems to have silently and
oh-so-helpfully converted your pretty curly quotes to ASCII quotes.
And therein lies the (hopefully short-term) problem with getting
beyond Latin-1.  Not that we can't support the higher characters, but
that the current infrastructure will *silently* introduce bugs when you
send such code around.  It's even a little bit risky sending Latin-1,
but at least that tends to produce complete gobbldygook when it fails.

So the best we could do right now with the quotes would be to allow them
but to require you not to use them with semantics different from plain
ASCII double quotes.

Makes me wonder whether we can set up some automated way to at least
detect such accidental de-unicodification.  Even just knowing the maximum
intended codepoint in the message might help detect most such errors.
Or even just knowing that *any* characters above 255 were intended...

Larry


Context and coercion

2006-04-03 Thread Joshua Choi
Kudos to all on the Perl 6 mailing list,

What's the conceptual difference (or relationship) between context and type
coercion? Is
$moose.prefix:~
the same as
$moose.coerce:as(Str)
for instance?

And forgive my brain, but how would you nicely define coercion in a class?
Like, could you spare an example?

Also, what's the point of making a whole grammatical category for coerce
that behaves like an infix operator?

Thanks in advance.


Re: Context and coercion

2006-04-03 Thread Larry Wall
On Mon, Apr 03, 2006 at 07:23:28PM -0700, Joshua Choi wrote:
: Kudos to all on the Perl 6 mailing list,
: 
: What's the conceptual difference (or relationship) between context and type
: coercion? Is
: $moose.prefix:~
: the same as
: $moose.coerce:as(Str)
: for instance?

No difference.

: And forgive my brain, but how would you nicely define coercion in a class?
: Like, could you spare an example?

Currently something like:

multi submethod infix:as ($self: Str) {...}
multi submethod infix:as ($self: Int) {...}

or

multi sub infix:as (MyClass $self, Str) {...}
multi sub infix:as (MyClass $self, Int) {...}

: Also, what's the point of making a whole grammatical category for coerce
: that behaves like an infix operator?

In the current synopses there is no coerce grammatical category
any more.  Everything is subsumed under infix:as, at least this week...
There's some discussion about whether it should simply be:

method as (Str) {...}
method as (Int) {...}

maybe with an is deep thrown in for good measure, but we haven't
quite got there yet.

Larry


Re: Context and coercion

2006-04-03 Thread Larry Wall
On Mon, Apr 03, 2006 at 08:24:51PM -0700, Larry Wall wrote:
: There's some discussion about whether it should simply be:
: 
: method as (Str) {...}
: method as (Int) {...}
: 
: maybe with an is deep thrown in for good measure, but we haven't
: quite got there yet.

Er, to have multiple of them in the same class, that would of course
have to be:

multi method as (Str) {...}
multi method as (Int) {...}

Generally, I love to travel.  Specifically, I love the fact that
jet lag is a such a convenient excuse for stupidity.

Larry