Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91719 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53108 invoked from network); 16 Mar 2016 22:17:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Mar 2016 22:17:05 -0000 Authentication-Results: pb1.pair.com header.from=narf@devilix.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=narf@devilix.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain devilix.net designates 209.85.218.44 as permitted sender) X-PHP-List-Original-Sender: narf@devilix.net X-Host-Fingerprint: 209.85.218.44 mail-oi0-f44.google.com Received: from [209.85.218.44] ([209.85.218.44:33050] helo=mail-oi0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 00/70-48430-06BD9E65 for ; Wed, 16 Mar 2016 17:17:05 -0500 Received: by mail-oi0-f44.google.com with SMTP id d205so49778642oia.0 for ; Wed, 16 Mar 2016 15:17:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=devilix.net; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=kk/Fx1BmTVPXt21b5+rCIuCJqKTbK9oFZYxC6NM+R3w=; b=f+9CsYYvKaTLHZtNGUXIhZx17l4BEVcP5l4EpiFco6iqrxmqstqxmRID55eMCsema+ 3HfKwi0lpGW7abjrtgENc5caSOiP3CeLS0Cjo/CCsJL8HQy0hjgzMXgzNk6i05Y/GyJP E+ObvoluI+npIiiHhjryf2rosa8XyVN9Jmq84= 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=kk/Fx1BmTVPXt21b5+rCIuCJqKTbK9oFZYxC6NM+R3w=; b=SwaIxFtYHqUFWizODlffE19AL7oU/i7v8oQxm07xcBQmhnXJqOOcj6xc9u++2o33Gc g2VTPWSHsF+yecOhPQPaTkVyM0EBtkrBGGrxEVt6EqaQ6S9CWnlLzk9/y8oTE2keeNzZ hnHZFeg+WqTnlIUhLXRTO/gc3x5S413t01pKc0HbrKN4wO6NtUWrTed6vP0tBY1FEDNm Ww3nHjTEO/B5KaQdUXTATs3J1jMdaNJ21hT4QkYT8wvm4vZ4TBhwyfqTjTrgVtlgHMSK p5cmDX0vwthGJ0X+FLaysPMQM0bkuHkpGa3/E+QscOTS7wNOc9cDlK2OEX2J7W78KhDp vnxg== X-Gm-Message-State: AD7BkJJAwMwtUKE7wXAEzeNZPT5+twsPDeVhKs6qvDph4A5h+yc832gyTV6mdEpwsUmiI4jvnwDf9kw9x1CRcw== MIME-Version: 1.0 X-Received: by 10.202.104.204 with SMTP id o73mr3913697oik.18.1458166621613; Wed, 16 Mar 2016 15:17:01 -0700 (PDT) Received: by 10.202.175.74 with HTTP; Wed, 16 Mar 2016 15:17:01 -0700 (PDT) In-Reply-To: <56E9D787.8070705@garfieldtech.com> References: <56E9AAF1.7070200@garfieldtech.com> <56E9D787.8070705@garfieldtech.com> Date: Thu, 17 Mar 2016 00:17:01 +0200 Message-ID: To: Larry Garfield Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a114087aa815273052e31df1c Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties From: narf@devilix.net (Andrey Andreev) --001a114087aa815273052e31df1c Content-Type: text/plain; charset=UTF-8 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. --001a114087aa815273052e31df1c--