Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65058 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83477 invoked from network); 21 Jan 2013 19:46:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jan 2013 19:46:19 -0000 Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.22 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.22 smtp2.ist.utl.pt Linux 2.6 Received: from [193.136.128.22] ([193.136.128.22:34532] helo=smtp2.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D2/81-08138-90B9DF05 for ; Mon, 21 Jan 2013 14:46:18 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp2.ist.utl.pt (Postfix) with ESMTP id CB4CF700048E; Mon, 21 Jan 2013 19:46:14 +0000 (WET) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp2.ist.utl.pt ([127.0.0.1]) by localhost (smtp2.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id dVlglECR7R85; Mon, 21 Jan 2013 19:46:14 +0000 (WET) Received: from mail2.ist.utl.pt (mail.ist.utl.pt [IPv6:2001:690:2100:1::8]) by smtp2.ist.utl.pt (Postfix) with ESMTP id 7221A7000488; Mon, 21 Jan 2013 19:46:14 +0000 (WET) Received: from damnation.nl.lo.geleia.net (a80-101-138-144.adsl.xs4all.nl [80.101.138.144]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id 283432002E21; Mon, 21 Jan 2013 19:46:14 +0000 (WET) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "Anthony Ferrara" Cc: "PHP internals" , "Nikita Popov" References: Date: Mon, 21 Jan 2013 20:46:12 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Organization: =?utf-8?Q?N=C3=BAcleo_de_Eng=2E_Biom=C3=A9di?= =?utf-8?Q?ca_do_I=2ES=2ET=2E?= Message-ID: In-Reply-To: User-Agent: Opera Mail/12.12 (Linux) Subject: Re: [PHP-DEV] [VOTE] Alternative typehinting syntax for accessors From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") On Mon, 21 Jan 2013 20:28:12 +0100, Anthony Ferrara wrote: > Gustavo > > I've voted "No" due to concerns I mentioned in most part in IRC, but > which >> I think should be here on the record. So my voting statement: >> >> I'm voting against this proposal because I think the proposed syntax >> strongly suggests that the property is bound to a specific type. This >> has >> several problems: >> >> * It's a promise that's not guaranteed. As long as the getter is allowed >> to reference the value of the variable can arbitrarily be changed to >> whatever type. It may also be possible to do the same with >> unserialization. >> > > This is pretty easily solved by removing the ability to return a > reference from the getter when the shortcut syntax is used. In fact, > remove the > ability to set the body of a getter at all (it would only allow you to > specify the visibility. If you need references, you can't use this > syntax... So now we have a new non-obvious special case for when a specific syntax is used. So much for the equivalence argument. Allowing no getter body has its own problems btw (lazy instantiation is no longer possible for instance). In any case, you leave unanswered other scenarios. Unserialization (and remember there are various unserialization implementations)? Bug in the setter (though I'm sure we could remove the ability to set the body as well)? Now what's your solution? PHP should start policing the type of the properties in all those scenarios? Maybe we should introduce Error exceptions for those runtime field type mismatches, like the JVM does. >> * The benefits are minimal. The only real benefit is cutting maybe two >> lines of code in an indisputably common scenario. >> > > Cutting two lines of code per instance. And considering that this is used > all the time, that can add up to some pretty significant (if not trivial) > boilerplate that's removed... > OK, so we disagree on the social value of removing, let's say 20 lines of boilerplate. But you still left unanswered my other concerns about the fact this actually transmits the idea that PHP will enforce the type of a variable. You may think that's not an issue; even then, I think this is a very important change that merits more discussion. It's interesting that you claim we "need a vision", but actually we could be about to start introducing a fundamental change in the language in an incremental backdoor fashion. -- Gustavo Lopes