Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82527 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68167 invoked from network); 12 Feb 2015 12:31:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Feb 2015 12:31:22 -0000 Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.213.182 as permitted sender) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 209.85.213.182 mail-ig0-f182.google.com Received: from [209.85.213.182] ([209.85.213.182:38378] helo=mail-ig0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CE/43-50473-81D9CD45 for ; Thu, 12 Feb 2015 07:31:21 -0500 Received: by mail-ig0-f182.google.com with SMTP id h15so3285611igd.3 for ; Thu, 12 Feb 2015 04:31:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:references:in-reply-to:mime-version :thread-index:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=Pv9cbHPxX5EEoVL8css/sgtkg7QwT3452AbKakHSW4Y=; b=jyMXCR65iRqWZ1u3bDDmDuqnSx98Ol04uAQ/do7Pk6NmqTL45O8IjrAFmnoPUvl562 /DAVL3J1ZL2+EbU6d67epPyeBKq4koeqhh7AMsH39I3SfN+SuzLCf/Ag5W8euLLSs6ic tN0D1g7VwknQoYWbYvukuOavAMVzTvtYtW2NJD1LlgEqU2/YAYJ8AbKzvPYLSN7NA17Q HGAOP8RVziPFLr3gCw5j/eBQi0X2pAsWlRB/2w2gG9kve/u1Qmap8MRbwZDYR3zx5wqw xQs8uTshBnXkH9EwLNmnzlIlK8WhxRX0EO0kCOpfjdBWBUsNqKu6jYapNcFiri+tpcIl 3sHQ== X-Gm-Message-State: ALoCoQlsyfuWU1A+/RKv5V90RVbqUfh1XBIHgwFmwgUrs6eSuUYN6MzB+QRFQeMnEkhmHZ2a9ToFLVy66tWRzmXepN+cPpGYRH+ZitEX05FNnDcVyAUs6OZoxITBeiasZxFZSTj2ncAuT9skgwF9cMVRoWZNDQ3lzA== X-Received: by 10.42.211.200 with SMTP id gp8mr8087892icb.93.1423744277084; Thu, 12 Feb 2015 04:31:17 -0800 (PST) References: <8703B53E-2C4A-4AC6-95C4-D4F19C6D5221@ajf.me> <54DAF884.7000508@lerdorf.com> <203e611c8e0b03568a868b8d931aec37@mail.gmail.com> <61E01A7C-C5C8-447F-A8FA-E12A18E847CA@ajf.me> In-Reply-To: MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQJMIZG9mXkdirFXmuP9r5ZK3xIuzQJbJJA/AzCIQggCYWllLQKBurkXAYsw6s4B6qYCMgHjX/2GAb5UKOABwylnMQKF/fUwm0bANtA= Date: Thu, 12 Feb 2015 14:31:15 +0200 Message-ID: <77a623e36dcc4b521d58a3f628180dbc@mail.gmail.com> To: Andrea Faulds , =?UTF-8?Q?Pavel_Kou=C5=99il?= Cc: guilhermeblanco@gmail.com, Rasmus Lerdorf , PHP Internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: RE: [PHP-DEV] [VOTE] Scalar Type Hints From: zeev@zend.com (Zeev Suraski) > From: Andrea Faulds [mailto:ajf@ajf.me] > Sent: Thursday, February 12, 2015 1:45 PM > To: Pavel Kou=C5=99il > Cc: guilhermeblanco@gmail.com; Zeev Suraski; Rasmus Lerdorf; PHP > Internals > Subject: Re: [PHP-DEV] [VOTE] Scalar Type Hints > > Hi, > > > On 12 Feb 2015, at 07:05, Pavel Kou=C5=99il wrote: > > > > On Thu, Feb 12, 2015 at 1:13 AM, Andrea Faulds wrote: > >> > >> A number (or numeric, or num, or some other name) type hint is > something I plan to propose in a future, follow-up RFC. > >> > > > > wouldn't polymorphism (via method overloading) solve the use cases and > > be much more useful in the long run than introducing a something > > that's not a type into type hints? > > PHP already has polymorphism through its dynamic typing. I don=E2=80=99t = see > method overloading happening any time soon. We have optional parameters > and dynamic typing, which all but eliminate the main needs for > overloading. > We=E2=80=99re a weakly-typed language, so overloading on scalar types mig= ht cause > unpredictable behaviour (with strict types you=E2=80=99d get an error som= etimes, > and > that=E2=80=99s fine - but calling an entirely different function? Now tha= t=E2=80=99s > different.) > There=E2=80=99s also the question of how, or if at all, method overloadin= g could > interact with our optional parameters and dynamic typing. Finally, > overloading can lead to really poor API design: it=E2=80=99s not that unc= ommon in > some languages to see 20 different function definitions with overlapping > and > non-comprehensive subsets of a method=E2=80=99s behaviour, that are disti= nguished > only by parameter types. It=E2=80=99s one of my least favourite Java/C#/C= ++ > features > for that reason. > > In response to saying numbers are not a type: well, they are more of an > abstract type which integer and float subclass. We already have internal > facilities for converting to and from =E2=80=9Cnumbers=E2=80=9D alongside= integers and > floats, > I don=E2=80=99t see why we can=E2=80=99t expose this to users. +1 Zeev