Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88766 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87079 invoked from network); 13 Oct 2015 10:59:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Oct 2015 10:59:37 -0000 X-Host-Fingerprint: 178.62.40.5 ajf.me Received: from [178.62.40.5] ([178.62.40.5:6189] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F0/52-04042-814EC165 for ; Tue, 13 Oct 2015 06:59:36 -0400 Message-ID: To: internals@lists.php.net References: <5C.21.16518.AA80C165@pb1.pair.com> Date: Tue, 13 Oct 2015 11:59:33 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:41.0) Gecko/20100101 Firefox/41.0 SeaMonkey/2.38 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 178.62.40.5 Subject: Re: [PHP-DEV] Scalar type hints and scalar type name aliases cause confuson From: ajf@ajf.me (Andrea Faulds) Hi Peter, Peter Cowburn wrote: > I would much rather we use the full names for these types across the board. I would mostly agree with you. Using the full English names whenever we're writing English, not code, makes sense. But we usually use int/float/etc. in code, like other languages do, and I don't see a good reason to change that. > The manual uses them almost exclusively, Not for type signatures it doesn't. It usually uses "int" and "bool". > and I'd hazard a bet that it is > many peoples' first choice when trying out the argument/return type > declarations. Yeah, and others will sometimes use them by 'mistake'. I know I certainly have. So we need to prevent this creating confusion. > Failing that, at least making them available as aliases is a good thing in > my book. I never understood the reluctance to make use of all existing > names when the type declarations discussions were going on. Fact is, people > are going to type "double", "long", etc. in their declarations... why get > in their way? I don't want to allow them as aliases, because it means another thing to add to style guides. Some people would use 'float', some 'double', some would use 'int', some 'integer', some 'long'. It'd be much cleaner to just pick one and stick with it. Types don't need multiple names. However, as you mention, many people are used to the other variants. So I'd like to reserve them and throw an error if you use them. Much better than people typing 'function format_number(double $number, long $digits)` and getting bewildered when it doesn't work. Thanks. -- Andrea Faulds http://ajf.me/