FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » error message I don understand
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: error message I don understand [message #174926 is a reply to message #174903] Mon, 18 July 2011 15:19 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
Denis McMahon wrote:

> Thomas 'PointedEars' Lahn wrote:
>> In the end an oversimplified, wrong explanation. It is a syntactical
>> requirement, not a functional one:
>>
>> $a = x();
>
> Here you're assigning the return value of the function x() to the
> variable $a.
>
>> $a[0] = 42;
>
> Here you're writing to the variable $a (or rather, in this case, to an
> element of the array that is variable $a).
>
> Neither of these is trying to assign (write) a value to the return value
> of the function call.

Yes, it is. The return value of the function is a one-element array, and
with that assignment I am writing to the same memory area (or another memory
area that holds a copy of the former's content) by changing the first
element of the array. IOW, the return value is _not_ read-only.

> Whether you call the issue syntactical or not is just irrelevant and
> messing about with semantics.

You are mistaken. The issue is a syntactical one, not a functional one,
because a function call (currently) cannot occur on the left-hand side of an
assignment expression in PHP, *regardless* of the return value of function
to be called.

IOW, it does not make sense to say that "the return value is read-only" as
the function is *never* *called* and *no* return value is obtained in the
first place then. This is a rather important difference because syntax
errors are detected by the parser upon (JIT-)compilation already.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Ouion Movement, Roun Time (Floating Point Time)
Next Topic: [MEMCACHED] Is there a way to get the expiration of a key?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 20:29:51 GMT 2024

Total time taken to generate the page: 0.05556 seconds