|
Posted by Erwin Moller on 11/18/02 11:42
ColdShine wrote:
> Erwin Moller in news:4416c095$0$11067$e4fe514c@news.xs4all.nl wrote:
>
>> I liked this discussion, and it cleared a few thing up I never
>> understood, and thus simply avoided in all my code.
>> Your examples are a nice summary. :-)
>>
>> Personally I think that it is a big mistake of PHP to let this construct
>> slip. :-/
>> Why try to be nice and 'correct' this internally to
>> $arr["key"] ??
>
> That's not a "correction", it's just... its behavior :)
Well... yes.
LOL. :-)
Reminds me of that old M$ joke:
Customer: "Dear Miscrosoft, I found again a bug in your software."
Microsoft: "No sir, sorry, that is not a bug, it is an undocumented
feature."
>>
>> Why obfuscate code with complex parameters inside (double) quotes?
>> What is the point? Outsmart fellow programmers? If so: go Perl. ;-)
>>
>> I think it is just unneccessary, and I never came across a situation
>> where it is actually needed...
>>
>> Well, just my 2 cents.
>> And thanks for the examples.
>> I finally got it, but will surely never use it. :-)
>
> You're welcome, but... why stick to not using a language feature?
>
> Look at this multiple string concatenation:
> $s = $a['first'] . '#' . $a['second'] . '(' . $a['third'] . ')';
> Becomes:
> $s = "$a[first]#$a[second]($a[third])";
>
> I found the latter syntax to be much clearer to read. And I suspect it's
> faster to execute too, since it probably saves some string concatenations
> (thus being less memory-intensive).
> And, as this syntax is clearly a short-hand to the more common "standard"
> syntax, why should constants be preferred over string keys, with string
> keys being much more common than constant keys?
erm... I am such an oldfashioned guy that rather writes a few extra lines so
it is completely clear what happens instead of a 'feature-guy' who tries to
keep things short and rely on less-well-known behaviour.
When I see:
echo "$arr[key.$another['key2']]";
I need a toilet first, and then I must THINK what it means, whereas the
longer notation is always clear.
But you are right: It is probably a little faster and a little memoryhungry,
but I always prefer clarity over speed and performance.
But hey: That is just me: I am absolutely not claiming my way is better. :-)
Like I said: puzzle-constructs in code were the main reason I walked away
from Perl.
Of course lots of people write readable Perl, but most dont. :P
At least not for a mere mortal like me.
Anyway, thanks for your examples.
Regards,
Erwin
>
> You can find the official samples here, if you like:
> http://www.php.net/manual/en/language.types.string.php#AEN3054
>
> If there's few people extensively using this syntax, it maybe due to the
> page it's documented into being too lengthy...
>
Navigation:
[Reply to this message]
|