Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88783 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30283 invoked from network); 13 Oct 2015 17:39:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Oct 2015 17:39:13 -0000 Authentication-Results: pb1.pair.com header.from=adam@adamharvey.name; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=adam@adamharvey.name; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain adamharvey.name designates 209.85.217.173 as permitted sender) X-PHP-List-Original-Sender: adam@adamharvey.name X-Host-Fingerprint: 209.85.217.173 mail-lb0-f173.google.com Received: from [209.85.217.173] ([209.85.217.173:36783] helo=mail-lb0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CC/C3-05441-FB14D165 for ; Tue, 13 Oct 2015 13:39:11 -0400 Received: by lbcao8 with SMTP id ao8so28929691lbc.3 for ; Tue, 13 Oct 2015 10:39:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adamharvey.name; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=+Je4CRNJsfz13yL8eyRK9TXVVrR1UIYJapv9/Z0IcPA=; b=p2jNiazCeCZdVhAxlybNexbutQAKusfzt84xA6mQIr5bjKdzjddLEQ2DPYHPn6hyw7 X/UPvda9HdXOAXD0sNWhPXW8rI8rvR6ql7mzfxZIoXuIQXK1j7mAbOhroWrnTdeAl0yL M0ZJhwlh3/C8E9p7VqGws6DwIWk0dM/5KffHo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=+Je4CRNJsfz13yL8eyRK9TXVVrR1UIYJapv9/Z0IcPA=; b=RtV5BNlJBdmp0gYjLGMLcJUM8AnY0lnez6+w0icuFEzt91jWkooj2Ub/24x5l7mK7g SYX6Tks2Y8QP95bRUiKMFsC7zh0tgLiUNIIxExBfm6N75qEB8friZq0lKB6L0o1z7kHk q1Nga2u1AczbLyTy9d7NgxAJC3t2chlShjOS0EpaFCjgcLq7BKsozKR+7GIhvBrfnoCh WhkaurQeMO8H4tCDwKGmjuXWMk9x8flPJbGE4YmdFUdfGV8AbD+vhfzemyrHLBJkFQBS dgOjP2cDPpBOSZhm3B9bsDMHWcX5yA/lthoKLFrxc6PLSL8fYJ+D8oZi4vMZZ05l3wL7 lY+g== X-Gm-Message-State: ALoCoQkFfc04zboVaYRP/hc/8uHcfEguBmrJmKp6bCyHXQtpwfFHJjcSDtEDKGgS94GtlDfsfbcu X-Received: by 10.112.209.71 with SMTP id mk7mr15707610lbc.46.1444757947718; Tue, 13 Oct 2015 10:39:07 -0700 (PDT) MIME-Version: 1.0 Sender: adam@adamharvey.name Received: by 10.25.154.139 with HTTP; Tue, 13 Oct 2015 10:38:47 -0700 (PDT) In-Reply-To: References: <5C.21.16518.AA80C165@pb1.pair.com> Date: Tue, 13 Oct 2015 10:38:47 -0700 X-Google-Sender-Auth: QzUaaFTqxmLWa9XZkEq3-YlbdlM Message-ID: To: Andrea Faulds Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Scalar type hints and scalar type name aliases cause confuson From: aharvey@php.net (Adam Harvey) (Sorry Andrea, I'm picking on your e-mail because it's easiest, but it's a general response to the thread.) On 13 October 2015 at 06:32, Andrea Faulds wrote: > e.g. > > $ ./sapi/cli/php -r 'function foo(): long {}' > > Fatal error: 'long' is not a valid type hint, use 'int' instead in > Command line code on line 1 > > This would completely solve the confusion issue, I think. A crystal clear > error message. It is a good error message, but I disagree with the premise behind it: > As I've said in a different email, I don't like the idea of allowing the > aliases because it'd be another set of coding style differences we don't > need. This lets us pick one name and stick with it, without causing > confusion. I agree that we should do something, but I think we should alias. We allow both "int" and "integer" in settype() and we allow it in type casting =E2=80=94 the two other places where a user can specify a type for conversion. I still think it's a poor choice to not allow both in type declarations: while I'm generally a fan of having one way to do things, I believe that the inconsistency in the language is worse than the potential ambiguity in style guides. Hell, _I_ still can't remember which out of "int" and "integer" is the right one, and I've now written a decent amount of PHP 7 code _and_ wrote half of the documentation for this. Plus, if we error when "integer" is used, we've moved people's cheese anyway (by disallowing the class name). Let's not compound that by forcing them to do busywork. Adam, who hopes that anecdote doesn't say more about his working memory than the design of the language.