Re: Context and coercion
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
Re: Context and coercion
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:(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: ($self: Str) {...} multi submethod infix: ($self: Int) {...} or multi sub infix: (MyClass $self, Str) {...} multi sub infix: (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:, 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
Context and coercion
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:(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: curly-quotes
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
[svn:perl6-synopsis] r8556 - doc/trunk/design/syn
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 %hash; # %hash is still empty But these ones I autovivify: my %hash; -my $val := $hash{foo}{bar}; +my $val := %hash; 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 +%hash = "foo"; # duh This rule applies to C, C, and C container objects.
[svn:perl6-synopsis] r8555 - doc/trunk/design/syn
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 I 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 I known named parameters, -similar to how hash constructors work: +This means a hash holding default values must come I known named +parameters, similar to how hash constructors work: # Allow "x" and "y" in %defaults be overrided f( *%defaults, x => 1, y => 2 );
Re: [svn:perl6-synopsis] r8553 - doc/trunk/design/syn
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}? %hash even. Luke
Re: [svn:perl6-synopsis] r8553 - doc/trunk/design/syn
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 C, C, and C container objects. > + >
[svn:perl6-synopsis] r8554 - doc/trunk/design/syn
Author: larry Date: Mon Apr 3 11:08:54 2006 New Revision: 8554 Modified: doc/trunk/design/syn/S05.pod Log: Mark Biggar points out that rule closure section had embedded closure verbiage. Modified: doc/trunk/design/syn/S05.pod == --- doc/trunk/design/syn/S05.pod(original) +++ doc/trunk/design/syn/S05.podMon Apr 3 11:08:54 2006 @@ -13,9 +13,9 @@ Maintainer: Patrick Michaud <[EMAIL PROTECTED]> Date: 24 Jun 2002 - Last Modified: 1 Apr 2006 + Last Modified: 3 Apr 2006 Number: 5 - Version: 13 + Version: 14 This document summarizes Apocalypse 5, which is about the new regex syntax. We now try to call them "rules" because they haven't been @@ -588,10 +588,11 @@ The closure is guaranteed to be run at the canonical time. -An B return from the closure binds the I for -this match, ignores the rest of the current rule, and reports success: +As with an ordinary embedded closure, an B return from a +rule closure binds the I for this match, ignores the +rest of the current rule, and reports success: - / (\d) { return $0.sqrt } NotReached /; + / (\d) <{ return $0.sqrt }> NotReached /; This has the effect of capturing the square root of the numified string, instead of the string. The C part is not reached.
[svn:perl6-synopsis] r8553 - doc/trunk/design/syn
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 C, C, and C container objects. +