Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64696 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68038 invoked from network); 8 Jan 2013 18:14:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jan 2013 18:14:02 -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.41 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.215.41 mail-la0-f41.google.com Received: from [209.85.215.41] ([209.85.215.41:33940] helo=mail-la0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 54/60-16636-8E16CE05 for ; Tue, 08 Jan 2013 13:14:01 -0500 Received: by mail-la0-f41.google.com with SMTP id em20so820865lab.14 for ; Tue, 08 Jan 2013 10:13:58 -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=aGrxgWkHD6pn1IU+DJEAp1pRly9K0VZPbfRv0ynMBZQ=; b=w5fRA+RGRHG/bgQquYIMkRtXhxGNDYovobBSfVhRY0DLVbevSL1PmepW0/4NaRfWn6 yNoV+SG41w3RYc8ZxjQpgKTfgwZR8Ih2fIXM+M7c7256E7E8IIbPMLHL2XDa00Q64wKn Xhlb/81a7dCJ/rJBCAE9qxxWyf8fOjn/E/dF7G07sAJxbz4qZlNN0NJV5sZUFZoYYnDJ 7bldWsGFsVPu3DRYpXIUWFNtk6CpoZr5JKg2PmRujnfJLOD5DPAwxF+nHoj4jK2C9I+h R3FsQymiIa4Gj2uGwqdu2rj8kjFp+6kvnM9awGk6O5V1r0tfrJxKG4DKL3Udqi7WBLaH tz9Q== MIME-Version: 1.0 Received: by 10.152.162.1 with SMTP id xw1mr63102241lab.3.1357668837881; Tue, 08 Jan 2013 10:13:57 -0800 (PST) Received: by 10.112.4.168 with HTTP; Tue, 8 Jan 2013 10:13:57 -0800 (PST) In-Reply-To: <50EC5F8F.8010703@mrclay.org> References: <4ED7146272E04A47B986ED49E771E347BB3D6ABCB3@Ikarus.ameusgmbh.intern> <50EC5F8F.8010703@mrclay.org> Date: Tue, 8 Jan 2013 19:13:57 +0100 Message-ID: To: Steve Clay Cc: PHP internals Content-Type: multipart/alternative; boundary=f46d042ef4a5cdf8b304d2cae839 Subject: Re: [PHP-DEV] [RFC] Alternative typehinting syntax for accessors From: nikita.ppv@gmail.com (Nikita Popov) --f46d042ef4a5cdf8b304d2cae839 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'm not going to argue whether or not determining nullability via = null is a good or bad idea, but it's the way things currently work in PHP. Adding other mechanisms for nullability (or multiple typehints, like it is your suggestion) is something that may be considered, but it is outside the scope of this RFC. Those things apply to typehints in general, not just to property typehints. If you want pursue this further, then I would ask you to create a separate RFC (or just a separate internals discussion maybe). Thanks, Nikita --f46d042ef4a5cdf8b304d2cae839--