
doy at tozt
Sep 10, 2012, 11:33 AM
Post #29 of 33
(55 views)
Permalink
|
|
Re: Perl 6 is not a menu (was Re: Named prototypes (again))
[In reply to]
|
|
On Mon, Sep 10, 2012 at 08:13:12PM +0200, Abigail wrote: > On Mon, Sep 10, 2012 at 12:52:33PM -0500, Jesse Luehrs wrote: > > On Mon, Sep 10, 2012 at 01:49:42PM -0400, David Golden wrote: > > > On Mon, Sep 10, 2012 at 1:41 PM, Nicholas Clark <nick [at] ccl4> wrote: > > > > [snip] > > > > 5) (state @a) = (1, 2); > > > > # needs to be equivalent to > > > > state @a; @a = (1, 2); > > > > [snip] > > > > a) it would be wrong to add (5) as something that is accepted by the parser, > > > > but compiled to something that Larry says is wrong > > > > > > I understand what you're saying. I'm questioning "...Larry says is > > > wrong". Or rather -- I'm questioning the context of Larry's view of > > > wrong. Starting from a blank slate (Perl 6), then sure, it should > > > work as Larry says. But we're not. And I think the utility of 4 > > > vastly outweights the utility of 5, since 5 can be accomplished with > > > nearly the same effect using "my" instead of "state". (Nearly in that > > > I think state might avoid some SV churn.) > > > > > > Perl 6 is not a menu, but nor should every design decision made for > > > Perl 6 be the gold standard for related design decisions in Perl 5. > > > Yeah, that was my feeling as well. Unless Larry specifically said perl *5* > should behave in the same was as perl 6, I don't think there's anything > wrong with implementing it more in a natural perl 5 way. > > > > For what it's worth, regardless of what Perl 6 does, I would expect case > > 5 to work as Nicholas describes, just based on how other similar > > features in Perl 5 work. > > I would expect not to be a difference between: > > (state @a) = (1, 2); > > and > > state @a = (1, 2); > > > You mention you base your opinion on "how other similar features in Perl 5 > work". Can you be more specific? Nothing immediately springs into my mind, > but Perl is a big language, and there may be something I'm missing. > > For > > (state @a) = (1, 2) > > to mean > > state @a; @a = (1, 2); > > is something I find surprising. And does it actually add any value? Is there, > for the user (the Perl programmer) any advantage to ever write: > > (state @a) = (1, 2) > > with the described meaning? I mean, for all intends and purposes, it acts > the same as > > my @a = (1, 2) What would (my $foo, state $bar) = @BAZ; do? Variable declaration and assignment are separate things, and everywhere else in the language, you can (scoping issues aside) replace a 'my $foo' wihtin an expression with 'my $foo' followed by the expression as-is, with the 'my' removed, as in "open my $foo, ..." vs "my $foo; open $foo, ...". A list assignment like "(state @bar) = (...)" is just a normal expression, and should be equivalent to what happens when you split up the declaration from the assignment, as in "state @bar; (@bar) = (...)". -doy
|