Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80627 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63840 invoked from network); 16 Jan 2015 09:05:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jan 2015 09:05:51 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.182 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.182 mail-wi0-f182.google.com Received: from [209.85.212.182] ([209.85.212.182:52085] helo=mail-wi0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 61/B4-39838-E64D8B45 for ; Fri, 16 Jan 2015 04:05:50 -0500 Received: by mail-wi0-f182.google.com with SMTP id n3so723919wiv.3 for ; Fri, 16 Jan 2015 01:05:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type:subject:from:date:to :message-id; bh=ZRra4NEZs1Wl6xX8Jh+hn/uAMX/n3chHkBKGtetnkrU=; b=przleEmWlB2mVLFvuuPlNkewP8rZJHEtRLXP0iHQyCQcwpjlhqR+s41pBdOu4gmthh yE04QhSFLGBsSQOyVstn9YuKnhzZJOJsovAlTB1mqFrFPIqD6T79iPv7cf+oKTh7e3lm kFvSVfK5PhB5di6wXe6/f29u3J7rLpXHVCl/YTe/Srd2RvthZ+JeXbmZnsbn2CNRpQNG oYhxtf87orhefZD6+VA5mRvsb5KVGv05s41zrJsiZosnjJAWwirmQUFKZOJkcmLzv/xA KY7DD3aFwCCXVLRe2Omphlge8/opdRPonPQX9qlc/vvzg4o+jR7/5fxTbFdrtElWItE8 ngQw== X-Received: by 10.194.185.68 with SMTP id fa4mr20274713wjc.111.1421399147016; Fri, 16 Jan 2015 01:05:47 -0800 (PST) Received: from [192.168.0.3] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by mx.google.com with ESMTPSA id c10sm5209564wjy.4.2015.01.16.01.05.45 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 Jan 2015 01:05:46 -0800 (PST) User-Agent: K-9 Mail for Android In-Reply-To: <54B86C63.6070802@gmail.com> References: <8DCD1B72-C81D-499E-B455-E4A042CD76E6@ajf.me> <4E2073DE-0951-498C-97BB-DDAC094F11FA@ajf.me> <9a033dd1f223f854e760924d118ab812@mail.gmail.com> <2ae0164cb9b9bf1c974d7a3c60af0466@mail.gmail.com> <6105ea99002e634373c09685310e26a6@mail.gmail.com> <85F6139E-6332-4645-91B8-C852B07EA62A@ajf.me> <12433808-9D62-48D3-B66E-74572C61BF68@zend.com> <54B85C2B.9000901@gmail.com> <54B86134.1020801@gmail.com> <54B86C63.6070802@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Date: Fri, 16 Jan 2015 09:04:40 +0000 To: PHP Internals List Message-ID: Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: rowan.collins@gmail.com (Rowan Collins) On 16 January 2015 01:41:55 GMT, Stanislav Malyshev wrote: >> debate. I'm just claiming that `(int) $num` is more explicit, has no >> BC breaks and should, IMMO, be the preferred choice. > >No, it should not be, and I just wrote two mails explaining why exactly >it should not. Here's the third. > >> Sorry, but this is the syntax used by the manual to describe >functions >> usage, not the actual implementation. The manual can be updated. The > >Of course, we can rewrite the whole manual and the whole language. You're muddling two things here: changing the notation in the manual would require absolutely no changes to the language, as long as it used a self-consistent notation to describe the language's behaviour. > The >question is - why we should make such huge changes if we already have >this meaning and it has been there for years and it always meant >exactly >that - coercive typing for scalars - and never meant anything else? Those reasons have been given many times; in summary, to keep the syntax for coercive hints distinct from the syntax for strict hints, rather than the same syntax meaning one for scalars and the other for non-scalars. >> implementation itself can't be changed after major version release. > >The manual is what people read and rely on. But there's a bigger issue >that you keep ignoring - that the functions having scalar typed >argument >*are* coercive *right now*. You describe it as if it's a typo in the >manual that can be fixed or something that happened by accident and >nobody intended it. Nothing can be further from the truth - it's how >weak typing has been always working in PHP. Now you are talking about the existence of the feature, not the syntax. It's a good argument for including coercive typing if any type hints are added, but internal functions will not need to be changed based on userland syntax. > You want new feature for >your use case? Fine, but claiming existing syntax for it and saying "no >problem we'd just rewrite the whole manual and disregard 20 years of >PHP >history" sounds like a bit too much to ask. There is no existing syntax in the language for scalar type hints of any kind. As for the manual, IIRC, there's already precedent for altering its conventions to match language features, when "callable" was introduced as a typehint; the manual previously used "callback" to annotate those parameters. The manual also uses return type on the left, but I don't think anyone's arguing that decides the discussion on that syntax, which will probably actually put return types on the right. It's just a convention in the manual which doesn't actually match any existing PHP code, and can be changed with no compatibility issues whatsoever. Regards, -- Rowan Collins [IMSoP]