Re: RFC: about class names as values

From: Date: Fri, 07 Jan 2011 09:33:12 +0000
Subject: Re: RFC: about class names as values
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-51239@lists.php.net to get a copy of this message
Hi, 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. > Closures are first-class citizens and it seems natural that they are so. Perhaps we should rethink what consistency means for PHP. I don't see any good reason why first-class objects could be evil, except that the $ could indeed be a problem. Regards, Adrian 2011/1/6 Johannes Schlüter <johannes@php.net> > 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 > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.internals (#51239) next »