Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88771 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95039 invoked from network); 13 Oct 2015 11:22:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Oct 2015 11:22:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=petercowburn@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=petercowburn@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.179 as permitted sender) X-PHP-List-Original-Sender: petercowburn@gmail.com X-Host-Fingerprint: 209.85.212.179 mail-wi0-f179.google.com Received: from [209.85.212.179] ([209.85.212.179:37496] helo=mail-wi0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9C/04-04042-869EC165 for ; Tue, 13 Oct 2015 07:22:16 -0400 Received: by wijq8 with SMTP id q8so26999748wij.0 for ; Tue, 13 Oct 2015 04:22:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=S2k+0KCu0Z1A5at9jCqboAD6g2y3nJY/FzKDHNYfoPw=; b=hfNRjzK5FJpSMhgVWdTa4TLmntLwoz5PWBoTWDMpwkXQFgDaKGDjWb+RQFpZ8cGcNz ML0u5ZdZ9a0kbw1hDZbsa5U3f+hw01G4C01frxgc2ecUHM9iM6Gyd/ON1TuQkMdyem6e h394kTH3wpb8SIj+ksjDL6aTRGBTkRvzADGlJHV9bpBQJElvonWBsC8g7J3YGvTnL8te 8RrmqxhTbPeYEtVWU5zFKqNM64qAxRJKqqBXGD6KWU0GU3TintsJbDWAGNB6/EBnpXKv KHOAN7zKDHZEy4JW21bG6oKkKjrSMAeZMIWm4EHrgEMPmPrtoyVV136/1FX97LsEmzsv IKPA== X-Received: by 10.194.75.169 with SMTP id d9mr35262000wjw.7.1444735333301; Tue, 13 Oct 2015 04:22:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.27.83.212 with HTTP; Tue, 13 Oct 2015 04:21:33 -0700 (PDT) In-Reply-To: References: <5C.21.16518.AA80C165@pb1.pair.com> Date: Tue, 13 Oct 2015 12:21:33 +0100 Message-ID: To: Andrea Faulds Cc: PHP internals Content-Type: multipart/alternative; boundary=047d7bb0433e5604ed0521faa8c1 Subject: Re: [PHP-DEV] Scalar type hints and scalar type name aliases cause confuson From: petercowburn@gmail.com (Peter Cowburn) --047d7bb0433e5604ed0521faa8c1 Content-Type: text/plain; charset=UTF-8 On 13 October 2015 at 11:59, Andrea Faulds wrote: > 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". I said "almost" for a reason. More clearly, we use the long names in prose and by convention the short ones in the function prototypes. > > > 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. I would say that more confusion will arise from trying to use something that comes naturally (e.g. "integer") and getting an error, than having it "just work". > > > 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. > So what if there is more than one way to say "hey, I want an integer here", particularly when they're super-duper common terms that are used everywhere. (I'm talking about "boolean" and "integer" specifically, however if someone wants to use "long", or "double", or "real" then why the hell stop them? > > 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. > -1 to throwing an error, that's just completely the wrong direction in my view. I'd much rather your example work. > > Thanks. > > > -- > Andrea Faulds > http://ajf.me/ > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --047d7bb0433e5604ed0521faa8c1--