Re: RFC: about class names as values
| From: | Johannes Schlüter | Date: | Thu, 06 Jan 2011 01:07:48 +0000 |
| Subject: | Re: RFC: about class names as values | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-51229@lists.php.net to get a copy of this message | ||
On Wed, 2011-01-05 at 21:53 -0300, Martin Scotta wrote:
> $obj = newInstance( MyClass ); // notice. undefined constant MyClass
This describes the major change with your idea.
What happens if a constant MyClass exists?
Another question is something like this:
<?php
function factory($class) {
return new $class();
}
factory( SomeClass );
?>
To proper support this we'd have to make classes first class elements.
For making this consistent it would make sense to make functions first
class elements. And best drop the $ in front of variables and create a
new language. Everything else becomes a mess.
johannes