> $ perl -le '$u=1; ($y=$u*=5)++; print $y'
> 6
It's interesting to note that this parse (due to precedence) as
($y=($u*=5))++, not (($y=$u)*=5)++
This is important for overloaded operators (which are going to become
much easier to do in Perl6). The importance arises if Perl6 allows
assignment to
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..
HaloO,
Michele Dondi wrote:
And yes: there are lots of languages having (e.g.) a ++ operator, mostly
"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
think that in C you can do (the equivalent of)
On Wed, 2 Nov 2005, Rob Kinyon wrote:
I think the difference comes from the Principle of Least Surprise. The
various operators being discussed in this thread are all operators
which are in languages that have common use - C, C++, Java, the .Net
stack, etc. Regexen and the various built-ins are g
On Wed, 2 Nov 2005, John Williams wrote:
surprises including operandless operators. Including mutating operandless
operators. What is s/// after all? Or is there a good reason for an
asymmetry between different classes of operators?
Well, s/// is a term, for one thing.
It is not so much an op
On 11/3/05, Michele Dondi <[EMAIL PROTECTED]> wrote:
> On Wed, 2 Nov 2005, Ruud H.G. van Tol wrote:
>
> >> http://www.nntp.perl.org/group/perl.perl6.language/17556
> >
> > I understand that Perl6 allows blocks with changed/enhanced syntax, so
> > it is or will become possible (to add it) as if it w
On Thu, 3 Nov 2005, Sam Vilain wrote:
That being said, there are probably other more pressing reasons that ops
should not accept $_ as default; I would guess, for a start, it makes
determining semantics very difficult. Does ++; mean &postfix:<++> or
&prefix:<++> ?
If we had it, I think we wo
On Wed, 2 Nov 2005, Ruud H.G. van Tol wrote:
http://www.nntp.perl.org/group/perl.perl6.language/17556
I understand that Perl6 allows blocks with changed/enhanced syntax, so
it is or will become possible (to add it) as if it was in the core
language.
Do I understand that right? Something as sim
Sam Vilain skribis 2005-11-03 11:01 (+1300):
> Does ++; mean &postfix:<++> or &prefix:<++> ?
I no longer think $_ defaulting for mutating ops is a good idea, but to
answer your question, read the original post: all these would imply the
LHS, so that makes ++ postfix.
Juerd
--
http://convolutio
On Wed, 2005-11-02 at 09:03 -0500, Rob Kinyon wrote:
> I think the difference comes from the Principle of Least Surprise. The
> various operators being discussed in this thread are all operators
> which are in languages that have common use - C, C++, Java, the .Net
> stack, etc. Regexen and the var
On Wed, 2005-11-02 at 11:46 -0700, John Williams wrote:
> It is not so much an operator, as it is a subroutine with really strange
> syntax, and the side-effect of changing the $_ variable. You need to use
> an operator to get it to affect a different variable.
operators _are_ subroutines. There
On Wed, 2 Nov 2005, Michele Dondi wrote:
> On Fri, 28 Oct 2005, John Williams wrote:
> > But IMHO the reduction in typing for this relatively minor issue is not
> > really worth the surprise to newbies at seeing operandless operators.
>
> I don't buy that argument as newbies are already exposed to
Michele Dondi:
> Ruud H.G. van Tol:
>> Or RPN-like:
>>
>> $x #= 2* 1+ 3/;
>
> Being a big fan of RPN myself (and considering it quite natural), I'd
> appreciate very much such a feature. I had asked myself about RPN
> features in P6, albeit in a probably unreasonable fashion:
>
> http://www.nntp.
On 11/2/05, Michele Dondi <[EMAIL PROTECTED]> wrote:
> On Fri, 28 Oct 2005, John Williams wrote:
>
> > But IMHO the reduction in typing for this relatively minor issue is not
> > really worth the surprise to newbies at seeing operandless operators.
>
> I don't buy that argument as newbies are alrea
On Fri, 28 Oct 2005, John Williams wrote:
But IMHO the reduction in typing for this relatively minor issue is not
really worth the surprise to newbies at seeing operandless operators.
I don't buy that argument as newbies are already exposed to all sorts of
surprises including operandless oper
On Fri, 28 Oct 2005, Ruud H.G. van Tol wrote:
Or RPN-like:
$x #= 2* 1+ 3/;
Being a big fan of RPN myself (and considering it quite natural), I'd
appreciate very much such a feature. I had asked myself about RPN features
in P6, albeit in a probably unreasonable fashion:
http://www.nntp.pe
On 10/28/05, Ruud H.G. van Tol <[EMAIL PROTECTED]> wrote:
> John Williams:
>
> > ($x *=2) += 1;
>
> Or ($x *= 2) ++;
>
> Maybe the comma should be taught a new trick:
>
> $x *= 2, ++, /= 3;
>
> meaning
>
> $x = (($x * 2) + 1) / 3;
>
> Or RPN-like:
>
> $x #= 2* 1+ 3/;
Oh, gee, why don't
John Williams:
> ($x *=2) += 1;
Or ($x *= 2) ++;
Maybe the comma should be taught a new trick:
$x *= 2, ++, /= 3;
meaning
$x = (($x * 2) + 1) / 3;
Or RPN-like:
$x #= 2* 1+ 3/;
--
Grtz, Ruud
> But IMHO the reduction in typing for this relatively minor issue is not
> really worth the surprise to newbies at seeing operandless operators.
AMEN!
Rob
On Tue, 25 Oct 2005, Juerd wrote:
> For comparison, here is the same code snippet again. First with, and
> then without explicit $_.
>
> With:
>
> given ($subject) -> $_ {
> $_ ~~ s/foo/bar/;
> $_++;
> $_ x= 2;
> $_ ~= "!";
> }
>
> Without:
>
> given ($su
On Tue, Oct 25, 2005 at 02:51:35PM +0200, Juerd wrote:
: For comparison, here is the same code snippet again. First with, and
: then without explicit $_.
:
: With:
:
: given ($subject) -> $_ {
: $_ ~~ s/foo/bar/;
: $_++;
: $_ x= 2;
: $_ ~= "!";
: }
:
: Wit
On Tue, Oct 25, 2005 at 05:26:32PM +0200, Juerd wrote:
: Michele Dondi skribis 2005-10-25 17:17 (+0200):
: > Hmmm... maybe you're right that $__ is too huffmanized (and hence
: > confusing) but $OUTER::_ is somewhat too few...
:
: for (1..9) -> $n { # ought to be more than enough
: e
Sebastian skribis 2005-10-25 9:17 (-0700):
> > I think it'd be great if +=, ~=, +&=, ++, etc, could all assume $_ on
> > their LHS when there is no obvious operand.
> It'd be nice to have these, but is it something that can wait? I
> wouldn't mind if more effort was spent on other pieces if this c
> I think it'd be great if +=, ~=, +&=, ++, etc, could all assume $_ on
> their LHS when there is no obvious operand.
It'd be nice to have these, but is it something that can wait? I
wouldn't mind if more effort was spent on other pieces if this can be
easily done in the future
- sebastian
On Tue, 25 Oct 2005, Juerd wrote:
for (1..9) -> $n { # ought to be more than enough
eval qq[
macro prefix:<\$_$n> { "\${ "OUTER::" x $n }_" }
];
}
And then you can use $_1 .. $_9. I think $_1 is much clearer than $__,
but I think neither is needed in the standard
Michele Dondi skribis 2005-10-25 17:17 (+0200):
> Hmmm... maybe you're right that $__ is too huffmanized (and hence
> confusing) but $OUTER::_ is somewhat too few...
for (1..9) -> $n { # ought to be more than enough
eval qq[
macro prefix:<\$_$n> { "\${ "OUTER::" x $n }_"
On 2005-10-25 11:17 AM, "Michele Dondi" <[EMAIL PROTECTED]> wrote:
>> I find $__ confusing, and prefer $OUTER::_, which already exists.
>
> Hmmm... maybe you're right that $__ is too huffmanized (and hence
> confusing) but $OUTER::_ is somewhat too few...
What's confusing about $__ is that it lo
On Tue, 25 Oct 2005, Juerd wrote:
Michele Dondi skribis 2005-10-25 17:05 (+0200):
Now, one that I've sometimes desired is a "two level" $_, i.e. a variable,
say, $__ referring to the _second next_ enclosing lexical scope. I am
aware that in this vein one may ask a third analogue and so on, but
Michele Dondi skribis 2005-10-25 17:05 (+0200):
> Now, one that I've sometimes desired is a "two level" $_, i.e. a variable,
> say, $__ referring to the _second next_ enclosing lexical scope. I am
> aware that in this vein one may ask a third analogue and so on, but let's
> face it: $_ already c
On Tue, 25 Oct 2005, Juerd wrote:
Reducing line noise isn't my goal, though. I feel that the implicit
defaulting to $_ makes Perl a more natural and elegant language, and
would like this principle being extended to these operators.
Indeed, both the implicit defaulting to $_ AND the availabilit
On Tue, 25 Oct 2005, Rob Kinyon wrote:
On 10/25/05, Juerd <[EMAIL PROTECTED]> wrote:
I think it'd be great if +=, ~=, +&=, ++, etc, could all assume $_ on
their LHS when there is no obvious operand.
[snip]
Especially bare ++ would be useful, I think.
Did you post this specifically to anti-a
Rob Kinyon skribis 2005-10-25 8:37 (-0400):
> Did you post this specifically to anti-address the fear that P6 will
> be more line-noise-ish than P5? :-p
No. Leaving out $_ is one of the important features in *reducing* line
noise. We're all very used to seeing it, but to most people it is just
tw
On 10/25/05, Juerd <[EMAIL PROTECTED]> wrote:
> I think it'd be great if +=, ~=, +&=, ++, etc, could all assume $_ on
> their LHS when there is no obvious operand.
>
> This clashes with &prefix:<=>, but that's nothing a space cannot fix.
> Same for lvalue subs called x or xx (or X or XX).
>
> m
33 matches
Mail list logo