Iain Barnett wrote:
> On 31 Aug 2010, at 02:07, Joel VanderWerf wrote:
> 
>> Use local vars or (scoped) contants?
> 
> Excellent, thanks. I didn't realise they could just be stuck into vars.

> Going back in time would be cool if it was in a time machine, but throwing out the good things learned over the years about things in computing seems the wrong way to do it. It's why I don't use PHP ;)

Actually one of the few nice things about namespaces in PHP is the
ability to import namespaces/classes using an alias.

use \foovendor\system\Shell as Sh;

Sh::exec( 'ls' );

And I like the convention (not imposed by PHP) to use lowercase
names for namespaces. In the example above it is immediately clear
that "\foovendor\system" is a namespace and that "Shell" is a class.

BTW: Given the Ruby example in following

module A
	module B
		class X
	end
end

it's still not clear to me if I should refer to the X class as
A::B::C or as ::A::B::C to make it obvious that this refers to
A::B::C in the top-level scope (::) and to avoid a lookup in the
local scope. (What are the best practices?)

My benchmarks show no significant performance improvement though
(whereas there is a noticable improvement in PHP).

Actually if you want the maximum performance out of PHP you end up
using fully qualified identifiers everywhere, e.g. \strlen instead
of strlen and \true instead of true (oh boy).


  Philipp