develooper Front page | perl.perl5.porters | Postings from June 2013

[perl #117689] [PATCH] perlop: document that it is the operator that determines the operation

From:
Tony Cook via RT
Date:
June 26, 2013 07:11
Subject:
[perl #117689] [PATCH] perlop: document that it is the operator that determines the operation
Message ID:
rt-3.6.HEAD-2552-1372230663-1581.117689-15-0@perl.org
On Fri Apr 26 13:45:11 2013, aristotle wrote:
> The meaning of `x` is dependent only on whether there are parentheses
> around its left operand or not. What any `x` means is known at compile
> time and depends only on the source text, never the run time values of
> its operands. This is just like most Perl 5 operators and is in sharp
> contrast to the bit ops whose behaviour depends *at run time* on the
> flag bits their operands.
> 
> It is as though Perl 5 has two different repetition operators that just
> so happen to look very similar (one spelled with parentheses followed
> by `x`, the other spelled with the invisible absence of parentheses
> followed by `x`), of which both are monomorphic just like most Perl 5
> operators.

That's not entirely true, () x acts non-() x in scalar context:

$ perl -le '@x = qw(a b); $, = ","; sub f { (@x) x 5 } print scalar f();
print f();'
22222
a,b,a,b,a,b,a,b,a,b

Thanks, applied as ae3f739188e3ee21fa593cafc28023c533e8d9bf with the and
-> an change mentioned by Daniel.

Tony

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=117689



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About