Re: Allow arbitrary expressions when using instanceof operator

From: Date: Thu, 06 Nov 2014 11:55:13 +0000
Subject: Re: Allow arbitrary expressions when using instanceof operator
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-78811@lists.php.net to get a copy of this message
On Thu, Nov 6, 2014 at 3:49 PM, Andrea Faulds <ajf@ajf.me> wrote: > By merging the symbol tables, you could reference classes like constants > (perhaps it’d return some sort of ReflectionClass-like thing?): > > $x = SomeClass; > $foo = new $x; > > Currently, because SomeClass above would resolve to a constant, you have > to use the weird pseudo-constant ::class: > > $x = SomeClass::class; > > It also would mean instanceof could accept arbitrary expressions, as > there’d be no syntactic ambiguity: > > class Foo {} > const Bar = ‘Foo'; > $x = (new Foo) instanceof Bar; // works (Bar resolves to ‘Foo’, valid > class name) > $x = (new Foo) instanceof Foo; // works (Foo is a class) > const Foo; // Not allowed, conflicts with class > Yeah, that makes perfect sense. Also, I just realized that HHVM accepts expressions wrapped in parenthesis. I might need to take a look at how it's done there. Daniel Ribeiro http://danielribeiro.org

« previous php.internals (#78811) next »