Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91721 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57198 invoked from network); 16 Mar 2016 22:23:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Mar 2016 22:23:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=pjsturgeon@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pjsturgeon@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: pjsturgeon@gmail.com X-Host-Fingerprint: 209.85.215.43 mail-lf0-f43.google.com Received: from [209.85.215.43] ([209.85.215.43:33710] helo=mail-lf0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 41/61-48430-AECD9E65 for ; Wed, 16 Mar 2016 17:23:38 -0500 Received: by mail-lf0-f43.google.com with SMTP id h198so29569734lfh.0 for ; Wed, 16 Mar 2016 15:23:38 -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; bh=ggja4ldp7wONzoJXhfdropOBlLV3cW4zuSO1DeLpB9w=; b=IjKyviZHHC3XqM6UbpPK1eA/5954i7my0yXBNQU6GxH6bSriI34AIP/GWDLop4WJcw NXat0A0rVywvm5RHAfbkHXxfRDLlycVrE63HFFK4rSOn9jPuIj5q5rwI7AVATwB7/0wo Xq7rlOYalRi3u9pp7fuF1RpQUchNDzjnAbQIOdfQQQYUMHiu0Ty4ERdK3d7nI1/OgR+g 29/EWkrUyjAze5TJ/9jux0+BqUuzOZlQ4RAZprWRXYnm+2HjlWKh7nIB7Bmzdgy1a8v7 CJWO4lawsre9NmcntPfPA47hN6v8l3voqcEYtqCx4Ngd8Kzggs3fZbbNFY3HmHQ44xuY nU7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=ggja4ldp7wONzoJXhfdropOBlLV3cW4zuSO1DeLpB9w=; b=nEn/7+UHd8DI+MevzvemkMqe+rK1G19WvicP6/dhI9TJBxHMjqOA7t4y1P0zlON/Y7 wXgraA28GzKUIi3GwZk9sFGFEbp18NPSinksMCMdNLD7dtHBjdTKFF/uXdwMQy1YJzsd 4EMMohgk1CUwvG0mMPDggSuR1kCAMT5ZYWxrp8Kbd6PVvhDKTxdvDiT3YLbi+oEDOM8H QI7//kucV/bB+0zuSxjIzaezfx1aNMPYNx8JxO1DiPgFAmNeVo7R0HG3cwrIVJuujWkE 0B//90/88nvdtutSGuovjNNOBHpWihbGRvi5h5kCkQOwyVo/5vwEAKGmhj8gY7DBm5EF njwQ== X-Gm-Message-State: AD7BkJKKqvgyZOZ0I6ZdzBEx0NZvoUk9bTb9qFuOsH19ETxFWAkcDGyIssVB3H4LbfmZw1qwxR6o232X+aFt8g== MIME-Version: 1.0 X-Received: by 10.25.162.144 with SMTP id l138mr2518571lfe.32.1458167015293; Wed, 16 Mar 2016 15:23:35 -0700 (PDT) Received: by 10.114.78.71 with HTTP; Wed, 16 Mar 2016 15:23:35 -0700 (PDT) In-Reply-To: References: <56E9AAF1.7070200@garfieldtech.com> <56E9D787.8070705@garfieldtech.com> Date: Wed, 16 Mar 2016 18:23:35 -0400 Message-ID: To: Andrey Andreev Cc: Larry Garfield , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties From: pjsturgeon@gmail.com (Phil Sturgeon) On Wed, Mar 16, 2016 at 6:17 PM, Andrey Andreev wrote: > On Thu, Mar 17, 2016 at 12:00 AM, Larry Garfield > wrote: > >> On 3/16/16 2:30 PM, Andrey Andreev wrote: >> >>> Also, a LOT of code would end up with e.g. a default value of 0 for an >>> integer property, still having to check if it was properly populated with a >>> positive value - not much of an improvement over NULLs. Cheers, Andrey. >>> >> >> That's fine. Type checking doesn't say that a value is correct or >> meaningful; it just enforces the shape of the data. >> >> Vis, type enforcement tells you that the property is an integer; it >> doesn't tell you that the integer is within the range of legal values for >> the temperature of a room. It tells you that a property is a string; it >> doesn't tell you that the string doesn't contain NSFW words. Those are all >> application-level concerns, not type-level concerns, no matter what we do >> here. (Just like they are for parameters and returns already.) >> >> IMO, int/string/float is only a big deal on properties if you're using >> reflection for DB schema generation or similar, as it lets you remove an >> annotation. (That's a useful benefit, though.) The bigger impact for me >> is for class names, so I can enforce a given object type on a certain >> property. Knowing "at least it's not NULL" has a much larger benefit in >> that case, as you avoid many "method called on non-object 100 execution >> lines later than the actual bug, good luck finding it" errors. :-) > > > Yet, your argument was about avoiding is_null() calls within application > logic and you'd gain nothing if you end up having to write ! empty() > instead. :) > I'd rather have a NULL to tell me that I have nothing instead of a > supposedly initialized but otherwise invalid value. > > Cheers, > Andrey. Not sure what you're saying there Andrey. > That's fine. Type checking doesn't say that a value is correct or meaningful; it just enforces the shape of the data. > Larry Solid points! Exactly that. A type relevant default of 0 is not definitively invalid, it's up to application logic to work that out. 0 is totally valid as an integer. I do quite like the idea of type relevant defaults being provided, so 0, [], "", etc, just like Go. The only trouble I see there is: what sane default is given for `public Foo $foo;`? Instantiate the class? Erf.