On Mon, 20 Jun 2011 18:27:48 +0200, Robert Eisele <[email protected]> wrote:
> 2011/6/20 Johannes Schlüter <[email protected]>
>> Yes. So having this in the current form accepted means that
>>
>> $a[-1];
>>
>> can have two meanings:
>>
>> 1) Get the last item (byte in a string)
>> 2) Get item `-1` (in an array)
>>
>
> Yes, sure. But if this feature is documented well, I can't see any
> problems with this, especially if the trend goes towards a more
> typed language where the user knows about the used data-type.
I consider having exact same semantics for two quite different operations
bad.
And I don't buy the "more typed language" argument.
What does
echo my_cool_function()[-1];
do?
>> Which are to different things.
>>
>> Currently we treat
>>
>> $a{$o} and $a[$o]
>>
>> as equal. My suggestion was to split this up to avoid the conflict from
>> above. I didn't suggest adding support for $a[-1] as last element for
>> arrays, I know quite well why this won't make sense.
>>
>
> I know about the equality of the two bracket forms. But I read somewhere
> that
> the trend goes towards [] - and maybe it was something from you.
There's no clear trend on this. It's a back and forth. Always depends on
the features we think about.
johannes
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php