Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:125485
X-Original-To: internals@lists.php.net
Delivered-To: internals@lists.php.net
Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5])
by qa.php.net (Postfix) with ESMTPS id 044D31A00BD
for ; Mon, 9 Sep 2024 21:35:19 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail;
t=1725917839; bh=xpr5skagGXg9cSQOody8TQhzFMRrinMAZoRWyD6nu2M=;
h=Date:Subject:To:References:From:In-Reply-To:From;
b=oNsORiDOgTJprLTnys9k1qn9ntfz/WhLqS8yjbXPL295RP+PVCyTzzJRN5nH7NWae
cDCC1If0zKhmo+lrA8oH2lLtaheG40287/4mCBC0C29UzTjlv/ZfU/XJqqiunlWPAA
3JdJXqX8jka1rcpmg/qDf/0QjX1JHLUN3dncPFvzqp+/cpAYthONzexKKIZALw5vM/
vIX3URQJzxvhU/7cJwVr3rmmgJF7TMhGQJ7Vocpv6l5CuPyTeLp9k8WW4qOt5S3adM
6SRuPUDfmM+JRZk+Vhq4dMt+daXAcryabF3p2xEIpPFrhuGG8cunZPJj2y+o/nn9wH
qOuQrBFo6fPTg==
Received: from php-smtp4.php.net (localhost [127.0.0.1])
by php-smtp4.php.net (Postfix) with ESMTP id 7B864180032
for ; Mon, 9 Sep 2024 21:37:18 +0000 (UTC)
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net
X-Spam-Level:
X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED,
DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE,
RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no
autolearn_force=no version=4.0.0
X-Spam-Virus: No
X-Envelope-From:
Received: from fout4-smtp.messagingengine.com (fout4-smtp.messagingengine.com [103.168.172.147])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
(No client certificate requested)
by php-smtp4.php.net (Postfix) with ESMTPS
for ; Mon, 9 Sep 2024 21:37:17 +0000 (UTC)
Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50])
by mailfout.phl.internal (Postfix) with ESMTP id A7CB81380246
for ; Mon, 9 Sep 2024 17:35:16 -0400 (EDT)
Received: from phl-mailfrontend-02 ([10.202.2.163])
by phl-compute-10.internal (MEProxy); Mon, 09 Sep 2024 17:35:16 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc
:content-type:content-type:date:date:from:from:in-reply-to
:in-reply-to:message-id:mime-version:references:reply-to:subject
:subject:to:to; s=fm1; t=1725917716; x=1726004116; bh=eLt95GP8cD
Ugmc6MW2BVX/ovQQOYLHT6J9IWaEn2WP8=; b=h00DT2lyAMoc/ypiPkft9C6RlZ
ei36SErX2IKxokxEvLWJUz3O4wsR52mVBRTUGEwXgEZ2mNDxO1KMK3Tbifv9l2rj
M5Mw9xcU3SjhkIS0bOM8GN02N5ByEOp1HFPd771e6tF5hQrdvsUTiH+1FeUA7MXp
K6DujZUXpQ38szQcV5+JYthBgElJCgEk30Vo2X8Jop+LCaVV5SRjzw5jj4tffrkq
bRYkI74TCj9YBUCpq1wyOGPIXhtKCGnV9mPUDCFHEJkAJ/i9yMghuQPCFVAdcmZk
sRgmR5fbv19m2MiUzdcSktb8B7O19Abl0WBNyfuesJvJhdKd1BELJmKwoXuw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
messagingengine.com; h=cc:content-type:content-type:date:date
:feedback-id:feedback-id:from:from:in-reply-to:in-reply-to
:message-id:mime-version:references:reply-to:subject:subject:to
:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=
fm1; t=1725917716; x=1726004116; bh=eLt95GP8cDUgmc6MW2BVX/ovQQOY
LHT6J9IWaEn2WP8=; b=okT9cElQOdIUf0JsMV0tCCHyd0wEfSVrqinYzRy+Z1kZ
/GvEjiBIPyNldeBz3VSxsDEQCe41y6KjReA5epGJbi3iEt6Ubd5DD3Euv7IO26iC
RZWTyxKDp6kLAn33xG+NxOfnI3XbPeQFkCQu13qYC/54FQiM4cxb8hL3Ey1yWrnn
AZufdytw1LhkgDWv5Pw/ywRMv10JclNHn9zVUE9PcDT5UTZ47aNuLifMNJV2Vy1m
mhdukqpBsGDGFN/zw2IgnSWdpTVIotSu1ONTp3wdoammUZ6gGGWIV54T1YfL7D0y
mTUhHQdCbHJfkCmxbTeawHenldjNGwzgpH1sdoBwHQ==
X-ME-Sender:
X-ME-Received:
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeikedgtdduucetufdoteggodetrfdotf
fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu
rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpegtkfffgg
gfuffvfhfhjgesrgdtreertddvjeenucfhrhhomhepfdftohifrghnucfvohhmmhhinhhs
ucglkffoufhorfgnfdcuoehimhhsohhprdhphhhpsehrfigvtgdrtghordhukheqnecugg
ftrfgrthhtvghrnhepheetleeiiefgueduieeuieffvdevheduueefkeejuefgffeftdei
tdegtedtleetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh
homhepihhmshhophdrphhhphesrhifvggtrdgtohdruhhkpdhnsggprhgtphhtthhopedu
pdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsth
hsrdhphhhprdhnvght
X-ME-Proxy:
Feedback-ID: id5114917:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA for
; Mon, 9 Sep 2024 17:35:15 -0400 (EDT)
Content-Type: multipart/alternative;
boundary="------------OT6I46SVotyjs0e01PZl4kq0"
Message-ID: <212fd466-85bc-4447-90b7-8fe5426d1bd1@rwec.co.uk>
Date: Mon, 9 Sep 2024 22:35:13 +0100
Precedence: bulk
list-help:
list-post:
List-Id: internals.lists.php.net
x-ms-reactions: disallow
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [PHP-DEV] bikeshed: Typed Aliases
To: internals@lists.php.net
References: <0fa39535-f22d-4eba-b4df-90abe39e683a@app.fastmail.com>
<79e58673-50ec-461e-a998-736b020e4287@app.fastmail.com>
<928A2984-6035-4DA6-9EA7-12E85237C270@php.net>
<0d461700-1b6c-44fd-9cda-aa698de49847@app.fastmail.com>
<667233C2-BC47-4530-8142-D90E6907FE63@daveyshafik.com>
<63d241a8-a34a-498c-a5f9-f34230aa5afa@app.fastmail.com>
<4C7A7F27-B787-44CA-B664-CEF4B9B412FB@newclarity.net>
Content-Language: en-GB
In-Reply-To: <4C7A7F27-B787-44CA-B664-CEF4B9B412FB@newclarity.net>
From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]")
This is a multi-part message in MIME format.
--------------OT6I46SVotyjs0e01PZl4kq0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
On 09/09/2024 19:41, Mike Schinkel wrote:
> Referencing prior art (e.g. Go) PHP could allow int literals — e.g. `1`, `47`, etc. — to be passed to typedefs derived from ints but require int variables to be typecast to the required type. Same for string literals.
That's an interesting compromise, worth considering.
> In Go you cannot add or subtract on a typedef without casting to the
> underlying type. I would definitely prefer that to be relaxed, but only
> if it is relaxed via an explicit opt-in, e.g. something maybe like
> this:
>
> typedef UserId: int operations: +, -, *, /;
> typedef UserName: string operations: .;
I think this would stray into some of the same complexity as operator
overloads on objects, in terms of the types and values allowed. For
instance:
typedef Metres: int;
assert( Metres(2) + Metres(1) === Metres(3) ); // most obvious
assert( Metres(2) + 1 === Metres(3) ); // seems pretty clear
$_GET['input'] = '1';
assert( Metres(2) + $_GET['input'] === Metres(3) ); // might be more
controversial
typedef Feet: int;
assert( Metres(2) + Feet(1) === Metres(3) ); // almost certainly a bad idea
Not unsolvable, but probably enough scope for nuance and debate that it
should be left well into Future Scope.
> type MyNewType: Foo
> type MyAlias = Foo
I know this was only an example, but as a general point, I think we
should avoid concise but cryptic differences like this. PHP is generally
keyword-heavy, rather than punctuation-heavy, and I think that's a valid
style which we should keep to.
--
Rowan Tommins
[IMSoP]
--------------OT6I46SVotyjs0e01PZl4kq0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
On 09/09/2024 19:41, Mike Schinkel
wrote:
Referencing prior art (e.g. Go) PHP could allow int literals — e.g. `1`, `47`, etc. — to be passed to typedefs derived from ints but require int variables to be typecast to the required type. Same for string literals.
That's an interesting compromise, worth
considering.
In Go you cannot add or subtract on a typedef without casting to the
underlying type. I would definitely prefer that to be relaxed, but only
if it is relaxed via an explicit opt-in, e.g. something maybe like
this:
typedef UserId: int operations: +, -, *, /;
typedef UserName: string operations: .;
I think this would stray into some of the same complexity as
operator overloads on objects, in terms of the types and values
allowed. For instance:
typedef Metres: int;
assert( Metres(2) + Metres(1) === Metres(3) ); // most obvious
assert( Metres(2) + 1 === Metres(3) ); // seems pretty clear
$_GET['input'] = '1';
assert( Metres(2) + $_GET['input'] === Metres(3) ); // might be
more controversial
typedef Feet: int;
assert( Metres(2) + Feet(1) === Metres(3) ); // almost certainly a
bad idea
Not unsolvable, but probably enough scope for nuance and debate
that it should be left well into Future Scope.
type MyNewType: Foo
type MyAlias = Foo
I know this was only an example, but as a general point, I think
we should avoid concise but cryptic differences like this. PHP is
generally keyword-heavy, rather than punctuation-heavy, and I
think that's a valid style which we should keep to.
--
Rowan Tommins
[IMSoP]
--------------OT6I46SVotyjs0e01PZl4kq0--