Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83682 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26992 invoked from network); 24 Feb 2015 18:49:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Feb 2015 18:49:40 -0000 Authentication-Results: pb1.pair.com header.from=pjsturgeon@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pjsturgeon@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.171 as permitted sender) X-PHP-List-Original-Sender: pjsturgeon@gmail.com X-Host-Fingerprint: 209.85.217.171 mail-lb0-f171.google.com Received: from [209.85.217.171] ([209.85.217.171:43492] helo=mail-lb0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F8/50-24698-3C7CCE45 for ; Tue, 24 Feb 2015 13:49:39 -0500 Received: by lbiw7 with SMTP id w7so26925859lbi.10 for ; Tue, 24 Feb 2015 10:49:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=WS+AUIuunKKHbK2GJmUz/BAsaKhaoh8/dpp+2VVL8T8=; b=gQZ4JkLbZsKDxGj8TzPo5t+TwrtyvVHHn4ttKqtRTczZflXZ4HVwp1Vr/RcY9PZRGo kQlXHFUPNGw31eIWC+3FY19tiBN00XroU51nCo2Z0S9zz5iMTWHl1MZuEla7ed0E/pQz /Hg1eIwKx+6dfauLl53F+C3xYC/i4khYj95vygw3BzxVNhaqK7iHrPKS1Wk+2499gsU1 sZjuc5hHMjSkoHT2I86L9LV3ohm/NLggM2Zad0yF71RgiHczeN9tItj8o6au1XrBaZAj +1Pn4iRfM2V7Ybc0XXNoruM5bN+DXpjzLyGB4noP2+gcMcSxj4R+pJOZSxKuaisg8a+h qUwg== MIME-Version: 1.0 X-Received: by 10.112.225.137 with SMTP id rk9mr382820lbc.11.1424803776426; Tue, 24 Feb 2015 10:49:36 -0800 (PST) Received: by 10.114.26.34 with HTTP; Tue, 24 Feb 2015 10:49:36 -0800 (PST) In-Reply-To: References: Date: Tue, 24 Feb 2015 13:49:36 -0500 Message-ID: To: "S.A.N" Cc: Mike Willbanks , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Anonymous Classes From: pjsturgeon@gmail.com (Philip Sturgeon) On Tue, Feb 24, 2015 at 1:37 PM, S.A.N wrote: > Would have been more useful, inline sintex like JSON: > > $object = > { > 'property': $value, > 'method': function (){...} > }; > > $object->property; > $object->method(); I know what you're saying here, and object literals like this would be rather interesting someday. They are, however, quite different to the concept of anonymous classes. JSON syntax would make it very hard for the usual PHP functionality to be used. Properties and methods look the same, visibility scopes cannot be used, implementing interfaces becomes impossible, traits dont have a home, etc. By the time you have catered to all of that you have something very different to JSON, and very different to PHP. Or, you have the syntax being proposed here, which is identical to existing declared class syntax other than there being no name. Another RFC to replace $foo = (object) [ 'foo' => 'bar' ]; someday would be nice, but that is not what this is up to.