note 92423 deleted from language.namespaces.importing by danbrown

From: Date: Thu, 23 Jul 2009 17:44:39 +0000
Subject: note 92423 deleted from language.namespaces.importing by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-158654@lists.php.net to get a copy of this message
Note Submitter: rasmus at mindplay dot dk ---- This is just not very useful. What would be useful, is if "use" worked as a block statement, allowing you to switch the execution context of a block to another scope, for example: file1.php: <?php namespace Helpers; function h1($str) { echo "<h1>$str</h1>"; } ?> file2.php: <?php require 'file1.php'; use Helpers { echo "<html><body>".h1('Hello')."</body></html>"; } ?> Without the ability to actually switch the default namespace execution context, it's just not much use at all - you will end up with the same amount of code you had before namespaces were introduced, you will just have backslashes separating your function/class-names instead of underscores. We already had a way of "namespacing" apps in this way, so this feature doesn't really help at all. Most people use one class per file, so you will still have to specify the namespace in every file, same way you did when you prefixed the names. I hope to see this function turn into something useful in the future...

« previous php.notes (#158654) next »