Hi,

I've got mixed feelings about this ...

On one hand, I've always avoided compact() because it is magic; a hack
that was very obviously made because there was no language construct
for it. This would've spared me lots of annoyance with code that was
already otherwise boring.
But on the other hand ...

> Yes, it is syntactic sugar to remove verbosity. Using compact() has two 
> problems for me:
> 1) It is verbose especially if the assoc-as-poor-man's-named-parameter 
> approach is used frequently. A bit like array() vs. [].

array() vs [] is an entirely different level of frequency. If you're
using compact() even remotely as much as arrays in general, it sounds
more like you're abusing those poor-mans-named-params. The use cases
for that should be limited to stuff like PDO's named parameter
markers, not literally every function.
And to speculate a bit, if your variable names always match the
desired array key names, then you're probably (and paradoxically)
already being verbose with stuff like $src = $url.

For the few valid use cases where the names do 100% match, compact()
(while I do hate it) already does the job and it isn't *that* verbose.

Cheers,
Andrey.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to