Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87015 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40638 invoked from network); 4 Jul 2015 08:56:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jul 2015 08:56:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.176 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.212.176 mail-wi0-f176.google.com Received: from [209.85.212.176] ([209.85.212.176:36545] helo=mail-wi0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1D/70-29126-DAF97955 for ; Sat, 04 Jul 2015 04:56:14 -0400 Received: by widjy10 with SMTP id jy10so124743026wid.1 for ; Sat, 04 Jul 2015 01:56:10 -0700 (PDT) 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=D+bOtSqoA6xFa//EGeklDdiycRCR1x/YBobWUacnK8s=; b=IQ0QBAJs2TlaCi3RqiY+6v8JO2q6k5F8mnWXTociVQfpjFkwsXwW5vktmnm4HACvgf 0A0/ENYGrrCHm+AWa+Ru0kC7qM/h/xIehvskRqFGQqD0lcus4NxRUNYZBU472ezZxgA7 StF61YT9BCfzCpohlBHlCgoSrfZB0RmXGVrDETHRqCvnP8CQ5rV/OQe0kvbgdmY0z7UG TbqLR1QGD3QCEpzl+fsb+F4poqzTQrzVwXkHQbOaqkXbi3f34IGBCRZnVscfQ8TttP/l MDIV1TbEd2deIe6eAUHQBNM26dk/0Kvh1EChUZqho//y7LaG5KmYnw6mYFT0Cdb9zsYU sF0A== MIME-Version: 1.0 X-Received: by 10.194.82.38 with SMTP id f6mr26904747wjy.16.1436000170513; Sat, 04 Jul 2015 01:56:10 -0700 (PDT) Received: by 10.27.79.200 with HTTP; Sat, 4 Jul 2015 01:56:10 -0700 (PDT) In-Reply-To: References: Date: Sat, 4 Jul 2015 10:56:10 +0200 Message-ID: To: Trevor Suarez Cc: PHP internals , Levi Morrison Content-Type: multipart/alternative; boundary=047d7bf0bfc20f9af3051a08d881 Subject: Re: [PHP-DEV] [RFC] Additional soft-reservations for PHP 7 From: nikita.ppv@gmail.com (Nikita Popov) --047d7bf0bfc20f9af3051a08d881 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sat, Jul 4, 2015 at 9:31 AM, Trevor Suarez wrote: > > On Fri, Jul 3, 2015 at 12:24 PM Nikita Popov wrote= : > >> Hi internals! >> >> In a previous thread on the topic [1] I promised to create an RFC for th= e >> soft-reservation of 'void', similar to a bunch of other reservations we >> have done for PHP 7. The RFC also includes 'enum' as an additional >> independent proposal, as I think this will likely be needed in 7.x. If y= ou >> have further suggestions for names or keywords that we are likely to nee= d, >> please point them out. >> >> https://wiki.php.net/rfc/additional_soft_reservations_for_php7 >> >> Thanks, >> Nikita >> >> [1]: http://markmail.org/message/ovvnz5p2o6q7ebjl > > > Yea, this is smart to get this going. I think it makes a lot of sense. I'= d > love to see "struct" added to this list, so we could potentially add a > value object structure of some sort down the road. > > As far as "prior art", you can see that there's already some interest in > this area: > > - https://twitter.com/auroraeosrose/status/616321058904350720 > - https://gist.github.com/auroraeosrose/2036d1d675a4bd254450 > - https://gist.github.com/Antnee/237334e1eb937892ad7a > > Anyway, yea. Makes sense to me. =F0=9F=91=8D > So there are two questions to answer here: a) How likely is it that this will be implemented in the near future? I've added "enum" to the list, because there is already an existing proposal, which I personally consider relatively likely to pass. Structs are as-yet a vague concept and may be implemented in very different ways. As far as I see the only fundamental difference between a "struct" and a "class" per the above definition is that you can't create dynamic properties on it - which is something that can be solved from a different angle as well (declare strict mode). b) Do we really need a keyword to implement this feature? For example, instead of "struct Foo {}" we could use the syntax "struct class Foo {}", in which case the new "keyword" would be "struct class" and we do not cause BC issues. Note that this also applies to "enum" where we could use "enum class Foo {}" instead. This syntax has precedent in C++11. Thinking about this now, this might be a better option, because there's a lot of code using "enum" in name segments [1] (it's pretty much the natural choice for userland enum implementations...) and introducing this keyword might result in a non-trivial amount of breakage (cc Levi). "struct" looks less problematic [2]. Nikita [1]: https://github.com/search?l=3DPHP&p=3D1&q=3Denum&type=3DCode&utf8=3D%E= 2%9C%93 [2]: https://github.com/search?l=3Dphp&q=3Dstruct&ref=3Dsearchresults&type=3DCod= e&utf8=3D%E2%9C%93 --047d7bf0bfc20f9af3051a08d881--