Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91717 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50600 invoked from network); 16 Mar 2016 22:00:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Mar 2016 22:00:43 -0000 Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 66.111.4.26 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 66.111.4.26 out2-smtp.messagingengine.com Received: from [66.111.4.26] ([66.111.4.26:38278] helo=out2-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D2/00-48430-A87D9E65 for ; Wed, 16 Mar 2016 17:00:43 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 311D421132 for ; Wed, 16 Mar 2016 18:00:40 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Wed, 16 Mar 2016 18:00:40 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=qbu1cPNRUcNwQA5 d5i3Pm3aJ3k8=; b=W5OdNuDj28dQ+AQoz7/9D8UY8OIM58/oGE4sjXnP/2rwUsx tdWJPUSUgIjTO/1cveDYhx+yt23if1YhaN9CbNqpJFeHB+fmNMOylK7Modyzzrj7 fsxdeQwckG0WXX8l3Yd5Pu3P196rCiSZRSjcEx0UpivtQZu2lzaRQuTKrzvU= X-Sasl-enc: 5ICCRt0z5FZud+VIH1JbKXnsP8cMKpT9F+Vdc3pquVoP 1458165639 Received: from Crells-MacBook-Pro.local (unknown [63.250.249.138]) by mail.messagingengine.com (Postfix) with ESMTPA id D995DC0001B for ; Wed, 16 Mar 2016 18:00:39 -0400 (EDT) To: internals@lists.php.net References: <56E9AAF1.7070200@garfieldtech.com> Message-ID: <56E9D787.8070705@garfieldtech.com> Date: Wed, 16 Mar 2016 17:00:39 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties From: larry@garfieldtech.com (Larry Garfield) 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. :-) -- --Larry Garfield