On Fri, 4 Nov 2005, TSa wrote:

"derived" from C. But Perl's C<++> already allows an extended syntax wrt that of those other languages, that is: I'm not really sure, but I don't
[snip]
Actually I'm not sure if Perl 6 allows

 ($u *= 5)++;

Since I wrote "already", I was referring to Perl5...

because the return value of *= is the rvalue 5 and *not* $u as
an lvalue. Correct me if I'm wrong. Otherwise how would the
expanded form

...but I don't have the slightest idea whether Perl6 will allow it or not. OTOH I feel like asking _why_ should it not? I mean: why "should" the return value of *= be the rvalue 5 and not $u as an lvalue, which would still return its new rvalue in rvalue context and be assignable in lvalue context?

behave when extented by yet another assignment

 ($y = $u = $u * 5)++; # $y++ or $u++

I think $y++ since it has been assigned the return value of the expression $u = ... which happens to be 5.

and recollapsed as

 ($y = $u *= 5)++;

 say $y; # 6?

it is definitely so in Perl5:

$ perl -le '$u=1; ($y=$u*=5)++; print $y'
6

At that stage you could drop the application to x and store the resulting
action in another variable C := (A * B) for later application. Writing the
above with Perl6 sigils would come out as

&A * &B * $x;

and then

&C = &A * &B;

Would not this be a sort of currying, thinking of this as a ternary operator that takes &A, &B and $x?

is a calculated code object just like

$y = $a * $b;

is a calculated value. This is what I would call first class operators!

But it depends on what C<*> is here. If that instead of being a multiplication of matrices which is (a somewhat specialized composition law but essentially boils down to a) composition of function, were a generic composition of functions, then yes: I'd like an easy enough form of syntactic sugar for that.

I remember having asked something akin to this in the context of what I would have considered a very natural syntax for doing something (but $Larry seemed to disagree) which implied map()ping a list of scalars into a list of closures to 'chain' (reduce?) them with a composition operator.

Briefly: ouch, This is what I would call first class operators too!


Michele
--
Whoa! That is too weird! I asked around among the math
faculty here and it turns out that _every one's_ wife is married to a mathematician!
- Dave Rusin in sci.math, "Re: Genetics and Math-Ability"

Reply via email to