Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81645 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35251 invoked from network); 2 Feb 2015 20:06:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Feb 2015 20:06:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lsces.co.uk from 217.147.176.214 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 217.147.176.214 mail4-2.serversure.net Linux 2.6 Received: from [217.147.176.214] ([217.147.176.214:52867] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9E/12-25089-6B8DFC45 for ; Mon, 02 Feb 2015 15:06:14 -0500 Received: (qmail 5932 invoked by uid 89); 2 Feb 2015 20:06:11 -0000 Received: by simscan 1.3.1 ppid: 5925, pid: 5929, t: 0.0745s scanners: attach: 1.3.1 clamav: 0.96/m:52/d:10677 Received: from unknown (HELO ?10.0.0.8?) (lester@rainbowdigitalmedia.org.uk@86.189.147.37) by mail4.serversure.net with ESMTPA; 2 Feb 2015 20:06:11 -0000 Message-ID: <54CFD8B3.9080208@lsces.co.uk> Date: Mon, 02 Feb 2015 20:06:11 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] What do we need strict scalar type hints for? From: lester@lsces.co.uk (Lester Caine) On 02/02/15 09:12, Dmitry Stogov wrote: > could you please write down few use cases, when strict scalar type hints > are really useful. Do we NEED strict scalar type control ... No Are there situations where strict scalar type control may be useful ...Yes Can a library be built ONLY using strict scalar type control ... Maybe ... provided that it only requires a set of data that can be 'strict' Much has been made of the idea that automatically causing errors when a wrong scalar type has been passed will simplify things, and in some cases that may be true, A few examples have been thrown up which suggest that integer values are a magic bullet when dealing with time or currency for example, but only some elements of that can easily be constrained to integers, other parts will require float or even string. When there is an error in any of this would one not expect any good library to produce a sensible set of error messages? A generic 'value not integer' needs to be augmented, so error checking against those elements that may be constrained would be mixed with error checking with the more weakly typed elements anyway? I can see that for some cases there may be an advantage but would it not be better to provide something that can act as a validity check against any input rather than some limited set of data? One 'class' that can identify where a scalar can be constrained or give a more relaxed result when required ... rather than having one rule for one and one for the other? -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk