Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58414 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45515 invoked from network); 1 Mar 2012 14:55:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Mar 2012 14:55:23 -0000 Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qw0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:51031] helo=mail-qw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A8/38-46815-4DD8F4F4 for ; Thu, 01 Mar 2012 09:55:17 -0500 Received: by qaui11 with SMTP id i11so3049034qau.8 for ; Thu, 01 Mar 2012 06:55:14 -0800 (PST) Received-SPF: pass (google.com: domain of ircmaxell@gmail.com designates 10.224.168.79 as permitted sender) client-ip=10.224.168.79; Authentication-Results: mr.google.com; spf=pass (google.com: domain of ircmaxell@gmail.com designates 10.224.168.79 as permitted sender) smtp.mail=ircmaxell@gmail.com; dkim=pass header.i=ircmaxell@gmail.com Received: from mr.google.com ([10.224.168.79]) by 10.224.168.79 with SMTP id t15mr5371050qay.66.1330613714530 (num_hops = 1); Thu, 01 Mar 2012 06:55:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=yt6TOBAjDuSzLaGo9lGKC+yG2fBGcsAC9AgiSzFU62w=; b=UT6E+fOB+OxA3p4x6JF3GwsdYDAMsv8EZwosCj4coE1Lnv44vGGlyaQxKA1BMgt8rP 7V5if+rQuMLE8udlEukOYqKNA4bMXhfMkDPSnpQSwnfl7jfs/+W1hDpVQ9NCnZMQF/g2 EaUCufFJFguorHcBxUX/mNmCMRfupSzlSHy8w= MIME-Version: 1.0 Received: by 10.224.168.79 with SMTP id t15mr4482085qay.66.1330613714460; Thu, 01 Mar 2012 06:55:14 -0800 (PST) Received: by 10.229.233.71 with HTTP; Thu, 1 Mar 2012 06:55:14 -0800 (PST) In-Reply-To: References: Date: Thu, 1 Mar 2012 09:55:14 -0500 Message-ID: To: Adam Jon Richardson Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Scalar Type Intentions From: ircmaxell@gmail.com (Anthony Ferrara) Adam, Sure. Basically, if you alias the int hint to scalar: function foo(int $i) { } The following are all valid values for $i: $i =3D 1; $i =3D 1.5; $i =3D "1.9" $i =3D "foo" $i =3D true $i =3D fopen($file); So, in the future, if we wanted to implement loss-less casting (casting if possible without loosing information, but erroring otherwise, so passing "foo" to (int $i) would generate an error. This will change the meaning of the int type hint, so production code using it will break. Therefore we wouldn't be able to add magic casting because of BC breaks... Whereas if you implemented just the scalar hint without the aliases, it wouldn't be a problem at all to add them, since there would be no BC break at all... Anthony On Thu, Mar 1, 2012 at 9:33 AM, Adam Jon Richardson wr= ote: > On Thu, Mar 1, 2012 at 8:55 AM, Anthony Ferrara wro= te: >> >> Please do not implement int, float, etc as an alias to scalar. =A0That's >> going to cause nothing but trouble later on. =A0It will instantly close >> the door to any type of casting magic (due to BC concerns), be >> completely non-obvious ("I hinted for int, why is it a boolean?"), and >> cause nothing but confusion. >> >> If you only want to add a scalar hint, I'm fine with that (for now), >> but please only add the scalar hint, no aliases... >> >> Anthony > > > Anthony, can you provide an example so I can better understand your > concerns? > > Thanks, > > Adam