Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101438 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12218 invoked from network); 29 Dec 2017 15:04:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Dec 2017 15:04:49 -0000 Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 66.111.4.26 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 66.111.4.26 out2-smtp.messagingengine.com Received: from [66.111.4.26] ([66.111.4.26:37667] helo=out2-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6C/69-47595-099564A5 for ; Fri, 29 Dec 2017 10:04:49 -0500 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 22332211D4 for ; Fri, 29 Dec 2017 10:04:46 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Fri, 29 Dec 2017 10:04:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=U1uZLs70fbOfaGT7Q1oeJ14X0XYXA bvE0mEg3lw+Yzk=; b=fi7XJuDeKn/XS6JtaRrCNhmIL0BfQGolJpGg6qAIStn9f 7lVQ1RET3aD93etJceOuAAVMx4ll2RipK60Ahgv2OkiaaxXrYXjyXIWiOE/hwmbr 9Vkh0FAzmd2gbaEobzLd9row1d8F785UrCBaWe2BDHNJ4U3QxOuXVMF77HhcunOl pKMam4qHCsCsuFMPRLB2ABJEksGz9DokElJ5mWroCBCINNnkWL48RB7gckp71adp Osr2E8k/56sRS/F8pJAGw05cT2Ple/BgZAiqIvAEVTnsYt0ZsH+Vxk4Tf6V+gPb5 OZySQxhu3faDRj42kqHQl1y6Am9y4cCbKVzIwSiFA== X-ME-Sender: Received: from vulcan.localnet (216-80-30-152.s3222.c3-0.frg-ubr1.chi-frg.il.cable.rcncustomer.com [216.80.30.152]) by mail.messagingengine.com (Postfix) with ESMTPA id D0CC47E168 for ; Fri, 29 Dec 2017 10:04:45 -0500 (EST) To: internals@lists.php.net Date: Fri, 29 Dec 2017 09:04:41 -0600 Message-ID: <3355180.q5RlgGrfOd@vulcan> In-Reply-To: <69D86823-589C-41D7-9A3E-D6CB4A58D5A2@koalephant.com> References: <72392123-d37b-26df-6886-218f48205f8a@fleshgrinder.com> <69D86823-589C-41D7-9A3E-D6CB4A58D5A2@koalephant.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1943618.dqDXWSGqJQ"; micalg="pgp-sha256"; protocol="application/pgp-signature" Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Scalar Pseudo-type From: larry@garfieldtech.com (Larry Garfield) --nextPart1943618.dqDXWSGqJQ Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" On Friday, December 29, 2017 8:20:14 AM CST Stephen Reay wrote: > > On 29 Dec 2017, at 19:56, Fleshgrinder wrote: > >> On 12/29/2017 1:26 PM, Rowan Collins wrote: > >> On 29 December 2017 12:08:16 GMT+00:00, Fleshgrinder > >> > >> wrote: > >>> What is the use case for `int|float`? I mean, if f is able to > >>> process a `float` than f is able to process an `int` and since > >>> `int` is already automatically changed to a `float`, well, you're > >>> done. > >> > >> I think it is somewhat tedious if we discuss every possible pair of > >> types, just as it would be somewhat messy if we added a new keyword > >> for every combination we found a use case for. The beauty of a > >> general-purpose syntax is precisely that a user can use whatever > >> combination they need, and not use combinations they don't need. I'm > >> sure there are plenty of nonsensical or redundant checks that can be > >> expressed in other parts of the language, but that doesn't mean those > >> language constructs are useless or damaging. > >> > >> Regards, > > > > I agree and I do not intend to do so, I actually am not even questioning > > the usefulness of union and intersection types. I am more curious in > > regards to providing a `number` type. Seems useless to me. > > I'm not sure "number" as a predefined type union is necessary but int|float > would allow a method to accept either in strict mode, and as you said it > would also be useful for eg a formatting function. I think he's referring more to the fact that int -> float is the only auto-cast allowed in strict mode, so it's not a great example of where a scalar union type would be useful. Which is a fair point. Nonetheless, it sounds like we're all saying the same thing: The fact that there are cases where a union or intersection declaration would be nonsensical or arguably poor design doesn't change the fact that there are plenty of cases where they would be entirely sensible and very good design, and building a bunch of one-off custom unions (scalar, number, mixed, iterable, etc.) is a poor substitute. So to those who voted against allowing Foo && Bar as a declaration, why? More specifically, what would get you to change your vote to allow general union/ intersection types, so we don't need all of these one-offs? --Larry Garfield --nextPart1943618.dqDXWSGqJQ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQEcBAABCAAGBQJaRlmJAAoJEODDCsAxcWF3CmEIAMJ9FynVSZouHF4xt6jZXhYz cu2cFKcThzQXX+S19GuKeyRXPvDuh//UOdxtLy2rCWWQiFIiM/1rh6lEaKHjpAbJ PtaxitH4LaKcj7SeMCte23cqEOHlU/kZ8aOrluqkli4A0qZJYPh4D7kmo3hbZQk3 0CI2gA4o2tEXAtYRi7Otowyue96lGynSFWjZAVUouLMil6mkGC8GCiZkbNF8ybog jXl7vDPpX7slbC0OFmXUYsQwcH0oM1A2GIIi1vSMzGGodHDp2djIzN3nIhZ9wbx0 eWa2sZym8JCGiIWHGTBGwcZc1gcZjI+sP/aOaoHkfowAstbDr7l7n0ay9qJjaGs= =3Nwj -----END PGP SIGNATURE----- --nextPart1943618.dqDXWSGqJQ--