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
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
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)
$ 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 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
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 would
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 was in the
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:
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
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:
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 all
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, 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
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://convolution.nl
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 ($subject) {
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
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
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 we just go with:
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).
my $subject = foo foo foo;
given ($subject) {
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).
my $subject =
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
two
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
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
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 covers
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
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 looks too
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 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
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
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 can be
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
:
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;
: $_ ~= !;
: }
:
:
32 matches
Mail list logo