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

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

Thread Previous | Thread Next
From:
Moritz Lenz
Date:
May 6, 2013 18:33
Subject:
Re: [perl #117689] [PATCH] perlop: document that it is the operatorthat determines the operation
Message ID:
51853F44.5050309@faui2k3.org
On 04/26/2013 10:45 PM, A. Pagaltzis via RT wrote:
> * Moritz Lenz <perlbug-followup@perl.org> [2013-04-21 20:35]:
>> +There are a few exceptions though: C<x> can be either string
>> +repetition or list repetition, depending on the type of the left
>> +operand,
> 
> This one is not…
> 
>> and C<&>, C<|> and C<^> can be either string or numeric bit
>> +operations.
> 
> … at all like these.
> 
> 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.

so, how would you formulate it?

(There is even a third one: reverse() does either list reversal or
string reversal, but depending on the context, not on the type of the
arguments)

Thread Previous | Thread Next


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