Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80608 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11405 invoked from network); 16 Jan 2015 01:12:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jan 2015 01:12:11 -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.179 as permitted sender) X-PHP-List-Original-Sender: marcio.web2@gmail.com X-Host-Fingerprint: 209.85.217.179 mail-lb0-f179.google.com Received: from [209.85.217.179] ([209.85.217.179:57841] helo=mail-lb0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 91/42-33406-A6568B45 for ; Thu, 15 Jan 2015 20:12:11 -0500 Received: by mail-lb0-f179.google.com with SMTP id z11so16185424lbi.10 for ; Thu, 15 Jan 2015 17:12:07 -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=rbXCIIPyf2LJZnfXYJ6muBnSVhSsFt/OtBw4Y3nEEco=; b=lDuQFRJUPrA0857VgQBQvUKh5ras2ixk/Whgvi3E59MmL9aLvobrXhJoxXbSxdgj50 4zW5j4QRPlKxP6Rg0s8F5/qpqJMlcrzLBHZhNNInqkwabn0W6sfpELhVZ2Yi9J38VubZ il6NWCGp57wlq+aLaoI99YPkr8FeIyR3Az46YMJCnySJayvFXjcTU6V/EWH3RBidkIxQ a75BabGm1Ycls96PULilQ9bfikzPkYjqrH3pYrYeEgLaqPxxJmg/Mv/1fODLw45ARRlE 9fw8EG8UYMNyPR6IDPjG5Pq9qm1TBgCWvY/bliH5H3kD7/cpE3T4o8P5lVnNp06ubYv5 4NzQ== X-Received: by 10.152.87.12 with SMTP id t12mr12908012laz.31.1421370727682; Thu, 15 Jan 2015 17:12:07 -0800 (PST) MIME-Version: 1.0 Received: by 10.152.21.101 with HTTP; Thu, 15 Jan 2015 17:11:47 -0800 (PST) Reply-To: marcio3w@gmail.com In-Reply-To: <54B86134.1020801@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> Date: Thu, 15 Jan 2015 22:11:47 -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) > That's how all internal functions work. It looks like you didn't > actually read my argument but just repeated "I want my use case". Sorry, I read all you said and understood it perfectly. > I know you want strict typing. I even proposed the option for it. No, you're wrong. I NEVER EVER said we should have "strict typing" in detriment of coercive types simply because there is no general consensus about what "strict" means :) But I also don't want to have coercive type hints to occupy the best "syntax slot" that could be used for more strict type checks in the future, being "strict" a negotiable term that deserves more debate. I'm just claiming that `(int) $num` is more explicit, has no BC breaks and should, IMMO, be the preferred choice. You can disagree with that, of course, but don't quote "I want my use case" as being something I said, wished or even though. > But if you read "function bar(int $num)" in the PHP manual, coercive typing is > exactly what it means. That's how it has been since forever. Sorry, but this is the syntax used by the manual to describe functions usage, not the actual implementation. The manual can be updated. The implementation itself can't be changed after major version release. 2015-01-15 21:54 GMT-03:00 Stanislav Malyshev : > Hi! > >> 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). > > That's how all internal functions work. It looks like you didn't > actually read my argument but just repeated "I want my use case". I know > you want strict typing. I even proposed the option for it. But if you > read "function bar(int $num)" in the PHP manual, coercive typing is > exactly what it means. That's how it has been since forever. > > It has nothing to do with arrays, because - repeating it in like 10000th > time in this discussion - arrays are not scalars and PHP does not coerce > non-scalars, only scalars. You can make scalars work like non-scalars - > that would mean turning PHP into strongly typed language, like Python. > -- > Stas Malyshev > smalyshev@gmail.com