> Well, what's the different between the placeholder &foo and the sub
> &foo? That's the main reason why. Also, '&' already has a perfectly good
> meaning: binary AND with the function foo(). :) Not trying to be a
> smartass, but I think you understand what I'm trying to say.
Yes. '&' is misleading.
>
> I think if we have $var OP ^plh (eg $foo + ^bar) coders will know what
> that means, simply because you can't have a binary operation without a
> left-side, and you can't have two operators in a row (typically). IE:
>
> $foo ^ $bar # obvious binary op
> atan2($pi, ^zot) # obvious placeholder (shamlessly ripped)
> $foo + ^ $bar # invalid!! (two ops in a row)
> $bar = ^ $zot # invalid!! (no left-side)
> $zot **= ^foo # "what's that binary op doing there..
> # ..oh, that's a placeholder"
>
Good examples, thanks.
There's two potential solutions here:
1- Use '_'
2- Use '^', but increase the strictness of sub calls
I'd be happy with both. I'm with Damian that '__' looks cool, but I
understand that people typing in perl from a magazine (do people still do
that?) might get confused (mmm... comfy fence I'm sitting on here...) and
that '_identifier' is a well understood C idiom meaning something completely
different.
The second suggestion specifically relies on us deciding that barewords are
always evil, so that :
$a = foo; # Error! Evil bareword! Return to firey depths of hell!
becomes:
$a = &foo; # Ah yes, a subroutine call!
or:
$a = foo(); # Ah yes, another subroutine call!
which mean the same thing in perl 5.6, unless foo() is a constant sub in
which case one is inlined while the other isn't (but now I'm getting
pedantic...). And of course:
$a = ^foo * sin(^foo); # Couldn't be anything but a placeholder.