Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78828 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87008 invoked from network); 6 Nov 2014 23:50:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Nov 2014 23:50:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 108.166.43.91 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 108.166.43.91 smtp91.ord1c.emailsrvr.com Linux 2.6 Received: from [108.166.43.91] ([108.166.43.91:52544] helo=smtp91.ord1c.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F3/E0-15374-2490C545 for ; Thu, 06 Nov 2014 18:50:26 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp20.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 8723880499; Thu, 6 Nov 2014 18:50:23 -0500 (EST) X-Virus-Scanned: OK Received: by smtp20.relay.ord1c.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 19D6480226; Thu, 6 Nov 2014 18:50:23 -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:50:23 GMT Message-ID: <545C093E.3050901@sugarcrm.com> Date: Thu, 06 Nov 2014 15:50:22 -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: Daniel Ribeiro CC: 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! > 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 code clearer. > name. Also, is_a, since it's a function, is significantly slower than > instanceof, which is a construct (but of course you already now that). I find it very hard to accept this particular argument. First, if your code significantly depends on the speed of instanceof, you probably have some very uncommon code that does some very uncommon things. For such code, changing syntax of PHP may be not the best idea. Secondly, if we discover that the speed of is_a is a common problem, we can treat it - i.e. by converting it to opcode, etc. - but in general the argument "function calls are too slow in PHP so we should have duplicates for them" sounds wrong. They are not *that* slow and in most cases it's completely fine to use functions. If your particular code is so performance-sensitive that the speed of instanceof really matters so much that function call is not acceptable, maybe it's time for a little C extension? -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/