Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78827 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85495 invoked from network); 6 Nov 2014 23:45:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Nov 2014 23:45:59 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 108.166.43.107 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 108.166.43.107 smtp107.ord1c.emailsrvr.com Linux 2.6 Received: from [108.166.43.107] ([108.166.43.107:37019] helo=smtp107.ord1c.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id ED/80-15374-5380C545 for ; Thu, 06 Nov 2014 18:45:58 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp6.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 43703803F9; Thu, 6 Nov 2014 18:45:55 -0500 (EST) X-Virus-Scanned: OK Received: by smtp6.relay.ord1c.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id E8379803A0; Thu, 6 Nov 2014 18:45:54 -0500 (EST) X-Sender-Id: smalyshev@sugarcrm.com Received: from Stass-MacBook-Pro.local ([UNAVAILABLE]. [74.85.23.222]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA) by 0.0.0.0:465 (trex/5.3.2); Thu, 06 Nov 2014 23:45:55 GMT Message-ID: <545C0832.4060008@sugarcrm.com> Date: Thu, 06 Nov 2014 15:45:54 -0800 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Nikita Nefedov , PHP internals References: <545B3900.6070208@sugarcrm.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Allow arbitrary expressions when using instanceof operator From: smalyshev@sugarcrm.com (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-like expression} we also allow (generic expression) - then it would probably work. I'm still not sure I like it too much - for instance, if I saw something like the example above in the code review, I'd ask to rewrite it with a variable, since it's unreadable and all too easy to make a mistake. Variables are not that bad, and not everything needs to be a one-liner. > I would say that it's just not logical to have some operator that can > accept dynamic (runtime-defined) value but not an expression. Right now, many constructs do exactly that - they accept literal or variable (with some stretching of what "variable" is, esp. with uniform syntax RFC which allows to stuff quite a lot in a variable) but not generic expression. However, the same uniform variable RFC allows many operations now to accept expressions via (expression) syntax, so maybe we can expand on that further and allow this in any context where literal+variable previously were accepted. I.e. now FOO() accepts FOO being (expression) but new FOO() does not, which does seem a bit inconsistent. So maybe it can be done. I'm still not sure personally doing this is a good thing - it is too easy to make code completely incomprehensible with this - but maybe I'm wrong here. I think it may be worth asking Nikita Popov if if it's be feasible to extend his RFC to these cases. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/