Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80606 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7690 invoked from network); 16 Jan 2015 00:47:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jan 2015 00:47:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=marcio.web2@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=marcio.web2@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.169 as permitted sender) X-PHP-List-Original-Sender: marcio.web2@gmail.com X-Host-Fingerprint: 209.85.217.169 mail-lb0-f169.google.com Received: from [209.85.217.169] ([209.85.217.169:47598] helo=mail-lb0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B2/81-33406-ABF58B45 for ; Thu, 15 Jan 2015 19:47:55 -0500 Received: by mail-lb0-f169.google.com with SMTP id p9so16149224lbv.0 for ; Thu, 15 Jan 2015 16:47:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=YkECamBGVysI9XmooYKbsuKl71WjT/3wgjZa8D17Jok=; b=RHYJGA1BPWMqwOuLnc/sEGokm29T/rcY3fHdg21OBr/GTp4i/kydPFNsN+F2Q5J7JO xsFPXmdWt+pXHTYg9r9ZNLwQCMAJvNf6KI78CMiOb7D2nNeJkieAEnMrskE26wuXRBO0 AKpD4hFF+xdAasPX1x2pn8jJ4KPWxn/3L83VGLz0RDc6dErVruF1nl1RXFX64e0X7Sed Q/y5X6xBlov4rfP9SAfINipvJjizveIuMuoOoi5CjgpUCtC8Rk9yvDMF3zYyWCzBLJLA 1MX3D5+IOg88yvn7z8JITcuxypc/qr/FMJZudRvg9Mlm6E4497czRn6yD1XyqU5Nmnni L6ww== X-Received: by 10.152.27.130 with SMTP id t2mr12665933lag.28.1421369271315; Thu, 15 Jan 2015 16:47:51 -0800 (PST) MIME-Version: 1.0 Received: by 10.152.21.101 with HTTP; Thu, 15 Jan 2015 16:47:31 -0800 (PST) Reply-To: marcio3w@gmail.com In-Reply-To: <54B85C2B.9000901@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> Date: Thu, 15 Jan 2015 21:47:31 -0300 Message-ID: To: Stanislav Malyshev Cc: Andi Gutmans , Andrea Faulds , Zeev Suraski , Richard Quadling , Leigh , PHP Internals List Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: marcio.web2@gmail.com (Marcio Almada) Stanislav Malyshev, > I would rather have int $num for coercive typing - given that close to > 100% of existing typed functions - namely internal functions - mean > exactly that and are actually documented with this exact syntax. > [...] > As for strict, maybe it can be int! $num or something like that. I'm not > exactly supporting it, but out of what I have seen this would make the > most sense for me - it expresses the intent pretty clearly ("give me > int! or else!" :) and does not conflict with existing stuff. The hole point (at least for me) for being against `function bar(int $num){}` to achieve type coercion is that the syntactic equivalent code `function bar(array $numbers){}` won't do any coercion - (array) $numbers - because BC break would be too big to handle. Having `int|integer|bool|float|real|string` as coercive type hints while `array` is "strict" looks like an ugly hack (no pun intended). 2015-01-15 21:32 GMT-03:00 Stanislav Malyshev : > Hi! > >>> 1. Strict >>> function bar(int $num){} >>> >>> 2. Lax >>> function bar((int) $num){} > > I would rather have int $num for coercive typing - given that close to > 100% of existing typed functions - namely internal functions - mean > exactly that and are actually documented with this exact syntax. Yes, > there are some functions that do strict, but those are in most cases are > either close to bugs which nobody cares to fix since it's so narrow a > case or some very special cases of some complex API where type matters > for API-specific reasons. > > As for strict, maybe it can be int! $num or something like that. I'm not > exactly supporting it, but out of what I have seen this would make the > most sense for me - it expresses the intent pretty clearly ("give me > int! or else!" :) and does not conflict with existing stuff. > > Putting it on the table as a brainstorming exercise. > > -- > Stas Malyshev > smalyshev@gmail.com