Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80468 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4966 invoked from network); 14 Jan 2015 15:35:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jan 2015 15:35:05 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:40014] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D4/83-19120-8AC86B45 for ; Wed, 14 Jan 2015 10:35:05 -0500 Received: by mail-we0-f170.google.com with SMTP id w61so9499628wes.1 for ; Wed, 14 Jan 2015 07:35:00 -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=SIek7jb05cUZIXMPtvI2yb96JsXuKD6Pd08x56oGK/c=; b=BZCwsPKGYdcRgUHinhR5TnNEBaVj9y5X/UINq0n9xfb8aN1f+pNT73q+xmZgZEiQX/ fpxX5AzakBahg+Rj1N25+E+Nqb7p7xdI3+QGrXK4wEtbet7B/JxZmDOt5pbSb+lrMFRb vzwewRa6ICgqPN3ADlVixXRNElpwsnpH9HmZxy8R8Qh3gnE2lEObviadRgBJZMSLVovy KmiDNl8gmU7lVHxwHn/T52GSBd+4CFa8phSEcYWy8Silocbpf5xamtgF+7m4lF8rWXrt jzlLRsNysDW4L/U9RrDtBv1bkUDIN/xxNs+mv12QPBkV7cxV+25y88zVbt1YAS8sF1VT B3lg== X-Received: by 10.180.72.177 with SMTP id e17mr9647790wiv.42.1421249700367; Wed, 14 Jan 2015 07:35:00 -0800 (PST) MIME-Version: 1.0 Received: by 10.27.2.87 with HTTP; Wed, 14 Jan 2015 07:34:40 -0800 (PST) Reply-To: RQuadling@gmail.com In-Reply-To: References: <8DCD1B72-C81D-499E-B455-E4A042CD76E6@ajf.me> <4E2073DE-0951-498C-97BB-DDAC094F11FA@ajf.me> <9a033dd1f223f854e760924d118ab812@mail.gmail.com> <2ae0164cb9b9bf1c974d7a3c60af0466@mail.gmail.com> Date: Wed, 14 Jan 2015 15:34:40 +0000 Message-ID: To: =?UTF-8?Q?Pavel_Kou=C5=99il?= Cc: Zeev Suraski , Andrea Faulds , Leigh , PHP Internals List Content-Type: multipart/alternative; boundary=f46d043c7c168716b6050c9e7baa Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: rquadling@gmail.com (Richard Quadling) --f46d043c7c168716b6050c9e7baa Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 14 January 2015 at 14:00, Pavel Kou=C5=99il wrote: > > > PS: Personally, I find the "scalar" typehint idea useless and cannot > find a real use case for it. Richard, would you mind giving an > example? > The point of the 'scalar' typehint comes about because we need to reject non compatible types. Just like we do when we say array or callable. Currently, if we want a method/function to accept a scalar, then we cannot put any type hinting in and so we can supply an array, callable, class or interface. Being able to say 'scalar' would mean I can instantly inform the user that any scalar can be used and that no type juggling will happen automatically. For example, take ... Now in this example, sure the parameters will be juggled because of the + operator. But without the typehint, and the lack of operator overloading, you would get an error if non-scalars are supplied in the addition, rather than in the call. The + is fine, it is the wrong params to the function that should be the problem. And a scalar typehint is the better place I think. Now if we have polymorphic behaviour ... (OK, 'sum' isn't a perfect example, but you see the point I hope). Richard. --=20 Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY --f46d043c7c168716b6050c9e7baa--