Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64828 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35301 invoked from network); 10 Jan 2013 21:28:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jan 2013 21:28:23 -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.215.43 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.215.43 mail-la0-f43.google.com Received: from [209.85.215.43] ([209.85.215.43:47969] helo=mail-la0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E6/2F-02684-6723FE05 for ; Thu, 10 Jan 2013 16:28:22 -0500 Received: by mail-la0-f43.google.com with SMTP id eg20so1116536lab.2 for ; Thu, 10 Jan 2013 13:28:19 -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=FGH2/zvRGDBAADr/pnQVyS1bL3ON8BjxtT1LRNAQHeU=; b=AqWbuCkxJ5whYwdQ+cL9LsuboJgVcgqp8vM0vuJpaAvpVnHhJBWrf3LSEelEH6zXHb KGPvzRLysB8biJmaEPuOzEnEMpZrIEwp4xv6AhuX8KiBgx4xyk1tUI/2LgEZD5e+eGgk Ek0UqlR1SegwU32vFtS8Eenm9SOyEuin7khzoMvEhnLcilbABjlBe/fs8fkYjvbjxI3n Wkt0nCw51Wf+DsH1yIDnBLQdlDuskXqu6rFgrJypBcxED3gX2MNeixFvG+HZKHMYv5qE WmYpzLMxbD9ITW29uagFSVcA4TwtKCaeh+AJgd3+ice6388iAqZ8yYQKIbJNsbK06ne3 +XkA== MIME-Version: 1.0 Received: by 10.112.98.232 with SMTP id el8mr17761120lbb.121.1357853299235; Thu, 10 Jan 2013 13:28:19 -0800 (PST) Received: by 10.112.4.168 with HTTP; Thu, 10 Jan 2013 13:28:19 -0800 (PST) In-Reply-To: <50EC5F8F.8010703@mrclay.org> References: <4ED7146272E04A47B986ED49E771E347BB3D6ABCB3@Ikarus.ameusgmbh.intern> <50EC5F8F.8010703@mrclay.org> Date: Thu, 10 Jan 2013 22:28:19 +0100 Message-ID: To: Steve Clay Cc: PHP internals Content-Type: multipart/alternative; boundary=f46d0401f8e18edd3f04d2f5db4d Subject: Re: [PHP-DEV] [RFC] Alternative typehinting syntax for accessors From: nikita.ppv@gmail.com (Nikita Popov) --f46d0401f8e18edd3f04d2f5db4d Content-Type: text/plain; charset=ISO-8859-1 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 = 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 = null; > public Foo $foo = null; > > Sure, method signatures have special behavior based on a default value, > 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-syntax 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 two with the new syntax? Nikita PS: I hope I'm not interrupting all those heated annotations discussion too much ^^ --f46d0401f8e18edd3f04d2f5db4d--