Re: Re: Only variables can be passed by reference

From: Date: Sat, 06 Dec 2014 11:00:17 +0000
Subject: Re: Re: Only variables can be passed by reference
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-79455@lists.php.net to get a copy of this message
Yasuo Ohgaki wrote: > In languages, there are literal, constant and variable. Return value is > variable. > It's better to keep basic rule. IMHO. > > $top = array_pop(f2()); > > is better than > > $v = f2(); > $top = array_pop($v); > > Is there anyone who likes latter? > Are there any other languages behave like PHP? IMHO, the first snippet is confusing (the second as well, if $v is not used in the following code). Actually, you don't want to pop the top of the stack, but you want to simply get it without altering the stack at all. Therefore it seems reasonable to use a function called array_top() (or so) which takes its argument by value. -- Christoph M. Becker

« previous php.internals (#79455) next »