Re: Language constructs and callability
On Sat, 2013-07-20 at 14:28 +1000, Ryan McCue wrote:
> Sara Golemon wrote:
> > Well, now... to be fair... You could make them functions and use the same
> > parser trick the backtick operator uses. to map the non-parenthesized
> > versions.... feels messy though. I'd just hate to get stuck with a hacky
> > workaround like that for the long term.
>
> That's what I meant by the "backwards compatibility layer". Not saying
> we have to deprecate the use as a construct, but why can't we enable the
> use as a function (and hence, callback, etc)? It feels less cleaner from
> my point of view (userland).
There again is a thing we can't emulate using functions: The operator
precedence when using () with echo is "special":
php > echo(0) || print(1);
11
alright, that's weird isn't it? Anyways let's try to emulate using a
function:
php > function echo_func($foo) {
php { echo $foo;
php { }
php > echo_func(0) || print(1);
01
damn different result, ah, echo-func returns NULL maybe when we return
true?
php function echo_func1($foo) {
php { echo $foo;
php { return true;
php { }
php > echo_func1(0) || print(1);
0
still not. Reason is that currently in
echo(0) || print(1);
the expression (0) || print(1) is evaluated first and then the result is
passed to echo.
Maybe one might have designed it differently but more than 15 years into
the game it's hard.
johannes
Thread (22 messages)