Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109720 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 34929 invoked from network); 20 Apr 2020 16:45:50 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Apr 2020 16:45:50 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 62AAB1804CD for ; Mon, 20 Apr 2020 08:17:02 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS11403 64.147.123.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 20 Apr 2020 08:17:01 -0700 (PDT) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 854EE580 for ; Mon, 20 Apr 2020 11:17:00 -0400 (EDT) Received: from imap7 ([10.202.2.57]) by compute7.internal (MEProxy); Mon, 20 Apr 2020 11:17:00 -0400 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-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=heP5su WRaTVBoOCkZ5nHRoo8pgJXJCCLNLlrjiAuxUI=; b=1jet7FAAvov6Gs6jBrp3e6 82nz5T5fy3ZmtIY2D7S0lPeE1Bw02dvbH1vkQAfF/uW2TEDN6Wi2EQ+8e9oDpxlO o9ViPZ+4BMzuT6Ur60en0vBfx1lox5EQwVtnl7TVvLP3M6d5Xnx3G+KaK/AFpGvV xf4I9Wy+nWqkbUd9JFVf9LuCzOuftM3x1YWzk6/rwBcjkmCPDLT/3kajgPv30kF/ 6P3oqc8IsCxYxVndlMQGQuqnHvuci1ZzhXF4uPhHGvRulGe1KbpBcijKVd3csQF9 UGZmVeROn9alMYZ4FUvgH3Ii1D0GPMWSw/wbhn2rKw0dUeuQ5ZACMnZPl+qKh3Dg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrgeefgdekhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgrrhhr hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh eqnecuffhomhgrihhnpehphhhprdhnvghtnecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id D89A2180093; Mon, 20 Apr 2020 11:16:59 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.7-1152-g08c8976-fmstable-20200420v1 Mime-Version: 1.0 Message-ID: In-Reply-To: References: Date: Mon, 20 Apr 2020 10:15:40 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Mixed type From: larry@garfieldtech.com ("Larry Garfield") On Mon, Apr 20, 2020, at 9:15 AM, Sara Golemon wrote: > On Mon, Apr 20, 2020 at 8:52 AM Larry Garfield > wrote: > > > On Mon, Apr 20, 2020, at 6:17 AM, Dan Ackroyd wrote: > > > Here is an RFC for adding a 'mixed' type to the language: > > > https://wiki.php.net/rfc/mixed_type_v2 > > > > > > > I am not against this, but now that we have Union types what places are > > there where the currently available type declarations are insufficient? > > Resource seems like the only remaining gap where you'd be forced to use > > `mixed` instead of a union. > > > > I imagine some type combinations get pretty wide. Like, this is verbose AF. > > null|bool|int|float|string|array|object|resource Sure, but how often is that an actual description of what the code accepts? I... cannot actually envision what code would actually accept that mess. :-) With union types and stringable already on the way, I'm not sure what other non-hypothetical use cases would still be that fugly that you'd now need to fall back to `mixed`. (I still think intersection types are needed, but that's a separate matter.) There may be, but I cannot think of them. > For the long term good of the language I'd prefer type aliases (or typedefs > or usings or whatever you want to call them. > > use mixed = null|bool|int|float|string|array|object|resource; > use scalar = null|bool|int|float|string; > use number = int|float; Concur. > That said, baking 'mixed' in as an implicit alias of the above isn't > problematic for that future. > > -Sara Concur. --Larry Garfield