Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64842 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69560 invoked from network); 11 Jan 2013 03:31:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jan 2013 03:31:08 -0000 Authentication-Results: pb1.pair.com header.from=guilhermeblanco@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=guilhermeblanco@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.42 as permitted sender) X-PHP-List-Original-Sender: guilhermeblanco@gmail.com X-Host-Fingerprint: 209.85.219.42 mail-oa0-f42.google.com Received: from [209.85.219.42] ([209.85.219.42:40450] helo=mail-oa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2A/44-02684-B778FE05 for ; Thu, 10 Jan 2013 22:31:08 -0500 Received: by mail-oa0-f42.google.com with SMTP id j1so1390922oag.1 for ; Thu, 10 Jan 2013 19:31:05 -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=usS6curVofrLbB1Bprr0k9EbjMShjOtROu4pS7jtDL0=; b=H6dGlHoC1izIQDUCWTjHaOX0elrjgIjlbVuctQlNIYowq2PRfR3nzTr/uWmDslWqV6 Assv0WXPIUcbUJaCRDGsUo5xAjMy4rkigkrFlNJA9aIhwT+d8scLNyRI4T0Aa0OUGusG h0V3ZH+FrCqRUpGeSBGtz8iyyZrLWHSp9FUYxXkXj9urmV8viJhYe1wV5QoRrk6/x/mx 5pBx2XdmTiEJUOZ2V3hQf8k9NYlvdM76Cx2N9UpeMN/UnXCqmpcBAmObc7csKtaGEVS9 jSp0XiAh1SB3+Dqx4n6HESH/I+/I2f8zNmIaYj8oimGUplWXd83duqcbjQBILOprFK3G qM5Q== Received: by 10.60.171.11 with SMTP id aq11mr43361224oec.104.1357875065007; Thu, 10 Jan 2013 19:31:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.174.68 with HTTP; Thu, 10 Jan 2013 19:30:44 -0800 (PST) In-Reply-To: References: <4ED7146272E04A47B986ED49E771E347BB3D6ABCB3@Ikarus.ameusgmbh.intern> <50EC5F8F.8010703@mrclay.org> Date: Thu, 10 Jan 2013 22:30:44 -0500 Message-ID: To: Lazare Inepologlou Cc: Nikita Popov , Steve Clay , PHP internals Content-Type: multipart/alternative; boundary=bcaec54d3ed2e62e9504d2faec5f Subject: Re: [PHP-DEV] [RFC] Alternative typehinting syntax for accessors From: guilhermeblanco@gmail.com ("guilhermeblanco@gmail.com") --bcaec54d3ed2e62e9504d2faec5f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable We all agree that nullable properties need to be addressed. Now why just don't discuss a possible syntax and move on? Initializers, parenthesis around unsetters, etc can all be detailed and discussed later. Here are the proposed syntaxes: public DateTime? $date { get { ... } set { ... } } public DateTime $date =3D null { get { ... } set { ... } } public DateTime $date { get { ... } set($value =3D null) { ... } } public $date { get { ... } set(DateTime $value =3D null) { ... } } Now choose your options from 1-4 and move on... Sometimes you truly love to discuss instead of act. Tsc, tsc, tsc... Cheers, On Thu, Jan 10, 2013 at 7:24 PM, Lazare Inepologlou wro= te: > Nikita, > > > 2013/1/10 Nikita Popov > > > On Tue, Jan 8, 2013 at 7:03 PM, Steve Clay wrote: > > > > > On 1/8/13 2:56 AM, Christian Stoller wrote: > > > > > >> But the way 'nullable' properties are defined is not very intuitive > and > > >> unclean, in my opinion. Stas has already mentioned that. > > >> `public DateTime $date =3D NULL;` // this looks like the property is > > >> initialized with null, but it does not show that the property is > > 'nullable' > > >> > > > > > > Much agreed. After instantiation, these shouldn't behave differently: > > > > > > public $foo =3D null; > > > public Foo $foo =3D null; > > > > > > Sure, method signatures have special behavior based on a default valu= e, > > > but IMO: > > > 1. those semantics aren't entirely intuitive to begin with > > > 2. property initializers aren't method sigs > > > 3. the semantics would apply only to some properties > > > > > > > > > > > > public DateTime? $date; > > >> > > >> In C# the question mark after a type is a short hand for a generic > > >> Nullable type. > > >> > > > > > > I like that it's an established practice of doing exactly what we're > > > trying to do. > > > > > > Could we not just make it obvious?: > > > > > > public Foo|null $foo; > > > > > > > I updated the RFC to include the current state regarding default value > and > > nullability: > > > > > https://wiki.php.net/rfc/propertygetsetsyntax-alternative-typehinting-syn= tax > > > > One question that still needs to be discussed is what syntax regarding > > parentheses we want to use if this makes it. Currently both set { } and > > set($foo) { } style accessors are supported. Do we want to keep those t= wo > > with the new syntax? > > > > Nikita > > > > PS: I hope I'm not interrupting all those heated annotations discussion > too > > much ^^ > > > > > > In the RFC, one thing is not clear: How to provide typehints for nullable > properties that actually have accessors. > > Will it be like this? > > public DateTime $date =3D null { > get { ... } > set { ... } > } > > > > > Lazare INEPOLOGLOU > Ing=C3=A9nieur Logiciel > --=20 Guilherme Blanco MSN: guilhermeblanco@hotmail.com GTalk: guilhermeblanco Toronto - ON/Canada --bcaec54d3ed2e62e9504d2faec5f--