Re: [PHP-DEV] Allow arbitrary expressions when using instanceof operator

2014-11-08 Thread Daniel Ribeiro
On Fri, Nov 7, 2014 at 3:50 AM, Stas Malyshev wrote: > I find it very hard to accept this particular argument. Honestly, I find it hard it too. The reason I started this is that I tried to do something like $foo instanceof $bar->getClassName() and I got a syntax error. It looks very straightfor

Re: [PHP-DEV] Allow arbitrary expressions when using instanceof operator

2014-11-06 Thread Stas Malyshev
Hi! > This is exactly what I'm doing right now, requiring the expression to > always be enclosed in parenthesis. I think it's way better to be able to > do this instead of creating temporary variables just to assign a class Why? What's so bad in variables? It doesn't cost that much and makes you

Re: [PHP-DEV] Allow arbitrary expressions when using instanceof operator

2014-11-06 Thread Stas Malyshev
Hi! > Also one thing not mentioned in the initial letter - this will also allow > you to use expressions for new operator in the same way: `new > (str_replace('/', '\\', $classPath))()` - just an example. OK, if we apply it consistently - i.e. say anywhere that we allow literal or ${variable-

Re: [PHP-DEV] Allow arbitrary expressions when using instanceof operator

2014-11-06 Thread Daniel Ribeiro
On Thu, Nov 6, 2014 at 3:49 PM, Andrea Faulds 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

Re: [PHP-DEV] Allow arbitrary expressions when using instanceof operator

2014-11-06 Thread Andrea Faulds
> On 6 Nov 2014, at 11:43, Daniel Ribeiro wrote: > > On Thu, Nov 6, 2014 at 3:36 PM, Andrea Faulds wrote: > >> Perhaps, dare I say it, we should merge the constant and class namespaces >> in PHP7? Those are perhaps the least likely to conflict. It’d mean we could >> handle instanceof expressio

Re: [PHP-DEV] Allow arbitrary expressions when using instanceof operator

2014-11-06 Thread Daniel Ribeiro
On Thu, Nov 6, 2014 at 3:36 PM, Andrea Faulds wrote: > Perhaps, dare I say it, we should merge the constant and class namespaces > in PHP7? Those are perhaps the least likely to conflict. It’d mean we could > handle instanceof expressions, and we wouldn’t need to use ::class. Hi Andrea! I'm no

Re: [PHP-DEV] Allow arbitrary expressions when using instanceof operator

2014-11-06 Thread Andrea Faulds
> On 6 Nov 2014, at 09:29, Daniel Ribeiro wrote: > > On Thu, Nov 6, 2014 at 1:01 PM, Stas Malyshev > wrote: > >> You could of course require the expression to always be enclosed in (), >> but that produces weird syntax where some forms of instanceof work >> without () and some only with (). Gi

Re: [PHP-DEV] Allow arbitrary expressions when using instanceof operator

2014-11-06 Thread Daniel Ribeiro
On Thu, Nov 6, 2014 at 1:01 PM, Stas Malyshev wrote: > You could of course require the expression to always be enclosed in (), > but that produces weird syntax where some forms of instanceof work > without () and some only with (). Given that you can easily assign your > value to a variable, is i

Re: [PHP-DEV] Allow arbitrary expressions when using instanceof operator

2014-11-06 Thread Nikita Nefedov
On Thu, 06 Nov 2014 13:01:52 +0400, Stas Malyshev wrote: Hi! What I want to implement is the ability to allow arbitrary expressions on the second operand, so instead of having to write something like this: I'm afraid there's a problem with this. Arbitrary expressions include constants,

Re: [PHP-DEV] Allow arbitrary expressions when using instanceof operator

2014-11-06 Thread Stas Malyshev
Hi! > What I want to implement is the ability to allow arbitrary expressions on > the second operand, so instead of having to write something like this: I'm afraid there's a problem with this. Arbitrary expressions include constants, right? So what this means: var_dump($foo instanceof Bar); is

[PHP-DEV] Allow arbitrary expressions when using instanceof operator

2014-11-05 Thread Daniel Ribeiro
Good morning, internals! I would like to present to you an idea that I have for a syntax improvement for PHP. The basic idea is to allow arbitrary expressions when using the instanceof operator. Currently, the second operand can only be a constant reference or a string: $foo instanceof stdClass;