Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125538 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 661611A00BD for ; Fri, 13 Sep 2024 18:47:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1726253354; bh=f+WH4ZipbiS6ybws30i1QVIitta5WfM1z10SEax+W2s=; h=Date:From:To:In-Reply-To:References:Subject:From; b=SPwPTxZ3DOZHg5xpONVFB4upRSKLQox7NIDF6TzkATj39SDCLfRr3KinhyPqFCSUw qxR8iTL0ObSNTqCbWl2X6zsdxSdTVzz5QGPTxpB0+orJAUDtpYGSZiM+goKkwqMNND PWp7vk7P/pCxs0u3pTmrkqJQoZAfHJrTNAVgfmcMpKdjtS2MmjLyzYoxgBxx35Xw85 An3QaovFFoaoQD7jeytNYJZyGC8tEhKl1h+uj1rLVBJIRP2ivgR25lldm5KzeW259/ rRM+Spp+oSvLA0JLBYez1FNQthk5VqK2O+MuieK+wlgI7OA1ZIr8rJHyJRduuJCNX/ WWwZ2rue35ZZA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 22507180080 for ; Fri, 13 Sep 2024 18:49:13 +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,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh1-smtp.messagingengine.com (fhigh1-smtp.messagingengine.com [103.168.172.152]) (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 ; Fri, 13 Sep 2024 18:49:12 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id 258BD1140206 for ; Fri, 13 Sep 2024 14:47:09 -0400 (EDT) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-01.internal (MEProxy); Fri, 13 Sep 2024 14:47:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding: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=1726253229; x=1726339629; bh=wCeSI4hPOgaPOO3PC6Llp JeeQpycLYXRda/oL3PE51M=; b=VBgPeHYcF61nJPm/mgRT6SP9NjiOre/zVmB1t hPiuDdEVubzCSbiNxWpCjUoBT0BrM/OesIgSdx2fdnORPdbv/AM0MAptkoA0pVHF eAPUDtMPMRAtRqtXvP4YWkCdrZcLuY2B1sX1X2vZF7Fb4es/0xmUOn5nNirkx2kt ebamb6w75u71kITBbQZVI1crfC8U4+KVrGw7vr0MF5rTvKGTM3oCJcNeW1ka44fw llgQyWAoqf6Anxj+txaHkr8bJO9kHQK137Go4KK8GuZXI97MRG4ng6uu39E9sdV0 IYrRjrFv4QmCOQCeUgEtzDfows8OE3Wlo5rTKarWxEmiguS1g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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=1726253229; x= 1726339629; bh=wCeSI4hPOgaPOO3PC6LlpJeeQpycLYXRda/oL3PE51M=; b=r dUe/NF9cXdRRplzNb5Awpd7W5QSi52kGVgLY/dJydW8DcCEFyiFiUTx1Z7RRxPg5 5f2RTYPQfJluubbD9RTJIwtaZI393DaqtWiz/1jwhYWV0NOU8CD1FnSYznzsqOQT ZL4UGgPdQoPObPj6Uk7LYFKg4jbfkqnBAOQMwVDfGRe5Hgr/zQsY47GUu9lpg+6i LajhYWK8ZlaGzYK7ddGdJdcB65XkgMNUt2TrC+Sd+AM38AmPoJe2rReqHRMOoZbK I409UCucXDq2qJXcbOonHHnfJdLLCYmbCGFLlARy9QRwCbMTys+ySH5UqJ4s7UeL c3qOBJG1GlwV64Zdiwu6Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudejkedgtddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtgfesthhqredtredtjeen ucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfih gvlhguthgvtghhrdgtohhmqeenucggtffrrghtthgvrhhnpeffieeivdfhvdeguddttdeg teeiueegvefhteehfeeffeetudeitdehtdegjeeuieenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggt hhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpth htohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id C6C2C29C006F; Fri, 13 Sep 2024 14:47:08 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Fri, 13 Sep 2024 13:46:39 -0500 To: "php internals" Message-ID: <49f0d3f3-7977-4fee-94d3-cdc6b9e55526@app.fastmail.com> In-Reply-To: <212fd466-85bc-4447-90b7-8fe5426d1bd1@rwec.co.uk> 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> <212fd466-85bc-4447-90b7-8fe5426d1bd1@rwec.co.uk> Subject: Re: [PHP-DEV] bikeshed: Typed Aliases Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Mon, Sep 9, 2024, at 4:35 PM, Rowan Tommins [IMSoP] wrote: > On 09/09/2024 19:41, Mike Schinkel wrote: > >> Referencing prior art (e.g. Go) PHP could allow int literals =E2=80=94= e.g. `1`, `47`, etc. =E2=80=94 to be passed to typedefs derived from in= ts but require int variables to be typecast to the required type. Same f= or string literals.=20 > > That's an interesting compromise, worth considering. I have concerns about this. Mainly, it depends on what we would want a = typeef to *do*. Eg, if it's just an alternate name, then maybe. If, ho= wever, typedefs allow other functionality -- such as validation, additio= nal methods, etc. -- then primitive -> typeef is not a guaranteed total = function. Eg; typedef UserId: string is /\s{3}-\s{4}/ { public function groupId(): string { return substr($this, 3); } } Maybe that particular functionality makes sense to do, maybe not, that's= a separate discussion. My point for now is just that there are typedef= approaches where auto-up-casting would be frequently invalid, and proba= bly also designs where auto-down-casting would be invalid (or possibly v= alid). For now, we should keep all options on the table until we decide= which options we want to make impossible. >> In Go you cannot add or subtract on a typedef without casting to the=20 >> underlying type. I would definitely prefer that to be relaxed, but o= nly >> if it is relaxed via an explicit opt-in, e.g. something maybe like=20 >> this: >>=20 >> typedef UserId: int operations: +, -, *, /; >> typedef UserName: string operations: .;=20 Not to go further down this rabbit hole than is necessary, but I would m= uch rather see operator overloads adopted, along the lines of Jordan's p= revious RFC, and let typedefs implement that if them if sensible. There's probably yet another research project to do here. I'd volunteer= , but I now have a newborn taking up most of my time. :-) --Larry Garfield