Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78811 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33751 invoked from network); 6 Nov 2014 11:55:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Nov 2014 11:55:39 -0000 Authentication-Results: pb1.pair.com header.from=drgomesp@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=drgomesp@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.42 as permitted sender) X-PHP-List-Original-Sender: drgomesp@gmail.com X-Host-Fingerprint: 74.125.82.42 mail-wg0-f42.google.com Received: from [74.125.82.42] ([74.125.82.42:50826] helo=mail-wg0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F4/63-28384-9B16B545 for ; Thu, 06 Nov 2014 06:55:38 -0500 Received: by mail-wg0-f42.google.com with SMTP id k14so982414wgh.29 for ; Thu, 06 Nov 2014 03:55:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=2oxX5GXcuV+OS4fXQo5wpI19E3ggT/axF+Uo2y+Dbgk=; b=CMdwukZsSwg5xiHXKTH9r1dkSdbVV5dPdiFpF+vB2LxqxTfGh947a5yXZplmYHwKJB H7G0OgImOx6lHD4sswVoQbufDxWFFZc9sy8a4nC/JIT1xZDPmbJJpQto0SOPg7DUOHCK VaqAoGipAXHysFDS+V6haMhUTyVH6jBLYh3FCetd5EYcsVNLYDl1FtwTAlxF2Jcir/h6 XCrc7HZyDIdHJezYENALL3C0lu04+z94gRfOoLAuN+bid+Mr4lbcEJ39yMQWtgaYTqOC Vvwj61DGpUXlTTPlWVDjswGwt8yVPY8g7ejjs/hncY0MKSDqMJOfIKrlB20v50YoXWsJ 84ow== X-Received: by 10.180.221.129 with SMTP id qe1mr13844200wic.21.1415274934021; Thu, 06 Nov 2014 03:55:34 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.39.201 with HTTP; Thu, 6 Nov 2014 03:55:13 -0800 (PST) In-Reply-To: <13E1F1B8-D2DB-4BAF-95FD-E9AB7A7D1AA5@ajf.me> References: <545B3900.6070208@sugarcrm.com> <6FB6D82E-CF77-462D-8420-A1E37915EA13@ajf.me> <13E1F1B8-D2DB-4BAF-95FD-E9AB7A7D1AA5@ajf.me> Date: Thu, 6 Nov 2014 15:55:13 +0400 Message-ID: To: Andrea Faulds Cc: Stas Malyshev , PHP internals Content-Type: multipart/alternative; boundary=001a1133c8fab3b55a05072f5f17 Subject: Re: [PHP-DEV] Allow arbitrary expressions when using instanceof operator From: drgomesp@gmail.com (Daniel Ribeiro) --001a1133c8fab3b55a05072f5f17 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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=E2=80=99d return some sort of ReflectionClass-like thing?): > > $x =3D SomeClass; > $foo =3D new $x; > > Currently, because SomeClass above would resolve to a constant, you have > to use the weird pseudo-constant ::class: > > $x =3D SomeClass::class; > > It also would mean instanceof could accept arbitrary expressions, as > there=E2=80=99d be no syntactic ambiguity: > > class Foo {} > const Bar =3D =E2=80=98Foo'; > $x =3D (new Foo) instanceof Bar; // works (Bar resolves to =E2=80=98F= oo=E2=80=99, valid > class name) > $x =3D (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 --001a1133c8fab3b55a05072f5f17--