Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125469 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 72B721ADB3D for ; Sat, 7 Sep 2024 13:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1725715847; bh=JJCVnMHpa6d8pmRhwLj37MkzIlAbzY29aqkD2fzCjHM=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=CChBl6rvQBWJlfaSVoDn1AF9fR3xFy/bizWKEnjdLAeaEb35ZHWd1M8wpLhNCeMzT BLU56hX1oWUi72d5zI50i4FQn1Q0lIjrsQbYcoLCTqiofg/D41isTHP8Cqb1hLlPPI epnJp96nikW5Y8bdX/hdvwbFZMhrOskl46KMyk3MeHAvRys1DMJekc577lORF50liF WtdUxF4HUgCmatFr6Mhu2OyzphldPd1FGKtNdGgxsn/ZTqjFBmq8h0+k8T+ab+cQWG U2wT70B3KA83K1xsb539yl30CseVgeujQ3jcWbK99YUYLNLvFjEBXkGXBnKHiifQi2 nvwlI519MSKWQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F194E1801ED for ; Sat, 7 Sep 2024 13:30:44 +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,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh5-smtp.messagingengine.com (fhigh5-smtp.messagingengine.com [103.168.172.156]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 7 Sep 2024 13:30:43 +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 3914911401DD; Sat, 7 Sep 2024 09:28:43 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-01.internal (MEProxy); Sat, 07 Sep 2024 09:28:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc: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=fm2; t=1725715723; x= 1725802123; bh=o17ta+6jAZfHxzBYYkc9N6p6hWlc78sdSDtVxMP8Bng=; b=V aL+AvqA/TZe+UHnXgMGRl56k4n/FXBbFxP6LfeXlY706NvsgsaD1IVU3NGjFo22q +f1yO9Zl2gyFhRFFmI13krKXTYb+5hd415Zcq6AcPkjFgF+X3ZS0ajuMI2hFmnHB andAxlMVECrRLllqSu7TlBiQJVHX+Kgpl8+JnSipT83sGXhpdEMlrhzBLIGoFGn9 /Z7WMewn8ZnoXiCRBHNg5Y/wigX5fi4eav+XszQdHRvbN7OfmoEWlgwom0/v3fxY CnN6ogKR0h4PAqRNAh7uGW3+DkzcYRiAs9qhZ4b+oXHhazXO7qDsz1QCfmlSX247 p979FQ4K5Hxg+t/LHvguA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=1725715723; x=1725802123; bh=o17ta+6jAZfHxzBYYkc9N6p6hWlc 78sdSDtVxMP8Bng=; b=N1OYy9vUlFgklQ4W7IOkSsI8mt7nSy0dSBityOD2OC7s WugIXyfiNr7w+Fs670A7s01KDekGy8p0K8AdUOWSYnHWX7koKlpmVFqOXDbxx+Zz EO5Pwc8DT6Wj/kSm/2+qtsVIcwHRJCC/fJ3PFsbe730PqheV8CYAb3r2jCv2GEit QNrDxrE4sMEBwS5zQlkUP/GDfpIOq0qsJNk4xWk6LB0x2B6/y6vEksMiqP8QpGY/ zRbS2iU/OqjR29JuCeORmKDA69ml5fS+Ws3JOL5KmydzLctjR25TUlipv54PZkWi eWbk96rok4ylNrXyK5cD7mzKPBar8hqNu6LYdU+n3Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeifedgieejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvfevkfgjfhfutgesrgdtreerredtjeen ucfhrhhomhepfdftohgsucfnrghnuggvrhhsfdcuoehrohgssegsohhtthhlvggurdgtoh guvghsqeenucggtffrrghtthgvrhhnpeeiueethedvvdefjefhgfeiheelheehtdfhfeek jefflefgvedvkeduteejjedttdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehrohgssegsohhtthhlvggurdgtohguvghspdhnsggprhgtphht thhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehlrghrrhihsehgrghrfh hivghlughtvggthhdrtghomhdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhs rdhphhhprdhnvghtpdhrtghpthhtohepmhhikhgvsehnvgiftghlrghrihhthidrnhgvth dprhgtphhtthhopegurghvvgihsehphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id D9E15780068; Sat, 7 Sep 2024 09:28:42 -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: Sat, 07 Sep 2024 15:28:22 +0200 To: "Mike Schinkel" , "Davey Shafik" , "Larry Garfield" Cc: "PHP internals" Message-ID: <2bb2b656-aace-462d-b8e3-69d23593c6fd@app.fastmail.com> In-Reply-To: <71DEAAB9-D788-4EB9-A07F-E47211F92F78@newclarity.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> <71DEAAB9-D788-4EB9-A07F-E47211F92F78@newclarity.net> Subject: Re: [PHP-DEV] bikeshed: Typed Aliases Content-Type: multipart/alternative; boundary=3932e853f2484be3956cac3d6b98de5e From: rob@bottled.codes ("Rob Landers") --3932e853f2484be3956cac3d6b98de5e Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sat, Sep 7, 2024, at 14:42, Mike Schinkel wrote: > > On Sep 6, 2024, at 4:45 PM, Larry Garfield = wrote: > > Aliases can then be used only in parameter, return, property, and in= stanceof types. Extends and implements are out of scope entirely. >=20 > Is there a strong technical reason why extends and implements should b= e out of scope?=20 >=20 > There is definite utility for this, to create a local alias in a names= pace that can be used throughout the namespace rather than having to ref= er to the external namespace in many different places. >=20 > > On Sep 6, 2024, at 8:46 PM, Davey Shafik wrote: > > I would very much prefer to either go all in with an Enum-like (whic= h means that we can hang methods on to the value) or we need to distingu= ish between type hints for class-likes and type hints for not-class-like= s (*Bar anyone?). >=20 > Allowing methods also have definite value as most use-cases I have see= n in other languages alias in order to add methods, especially for enabl= ing support of interfaces. >=20 > Which, however, brings up an important distinction that other language= s have made and which I think PHP would benefit from addressing: >=20 > 1. Type Alias =3D> Different Name for Same Type > 2. Type Def =3D> New Type which has all the same properties and method= s of other type >=20 > e.g. (being hypothetical with the syntax; bikeshed away): >=20 > typealias LocalWidget: Widget >=20 > typedef MyWidget: Widget { > function foo() {...} > } >=20 > function doSomething(Widget $widget) {...} >=20 > $w =3D new LocalWidget; > doSomething($w); // This works, no problem as LocalWidget =3D= =3D=3D Widget >=20 > $w =3D new MyWidget; > doSomething($w); // This throws an error as MyWidget !=3D=3D= Widget >=20 > -Mike >=20 >=20 Hey Mike, Keep in mind there is already single-class aliasing with well-known beha= vior for both local and project-wide aliases. Local aliases are done thr= ough 'use' statements, and project-wide aliases can be created by using = the `class_alias()` function. I feel like any aliasing for primitive/intersection/union types should f= eel like an extension of that for local aliases. For 'project-wide' alia= ses, I'm open to much more different syntax, like typealias or even 'ali= as'. As far as extends/implements go, I plan to keep it the same for simple c= lass aliases as there is utility there and the RFC already covers this. =E2=80=94 Rob --3932e853f2484be3956cac3d6b98de5e Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Sat, Sep 7, = 2024, at 14:42, Mike Schinkel wrote:
> On Sep 6, 2024, at 4:45 PM, Larry Garfiel= d <larry@garfieldtech.com> wrote:




Allowing methods also have definite value as most use-cases I have se= en in other languages alias in order to add methods, especially for enab= ling support of interfaces.

Which, however,= brings up an important distinction that other languages have made and w= hich I think PHP would benefit from addressing:

=
1. Type Alias =3D> Different Name for Same Type
2.= Type Def =3D> New Type which has all the same properties and methods= of other type

e.g. (being hypothetical wit= h the syntax; bikeshed away):

typealias&nbs= p; LocalWidget: Widget

typedef  MyWidg= et: Widget {
   function foo() {...}
}

function doSomething(Widget $widget) {= ...}

$w =3D new LocalWidget;
= doSomething($w);         &n= bsp; // This works, no problem as LocalWidget =3D=3D=3D Widget
=

$w =3D new MyWidget;
doSomething($w);&= nbsp;          // This thro= ws an error as MyWidget !=3D=3D Widget

-Mik= e



Hey Mike,

Keep in mind there is already s= ingle-class aliasing with well-known behavior for both local and project= -wide aliases. Local aliases are done through 'use' statements, and proj= ect-wide aliases can be created by using the `class_alias()` function.

I feel like any aliasing for primitive/inter= section/union types should feel like an extension of that for local alia= ses. For 'project-wide' aliases, I'm open to much more different syntax,= like typealias or even 'alias'.

As far as = extends/implements go, I plan to keep it the same for simple class alias= es as there is utility there and the RFC already covers this.
<= div>
=E2=80=94 Rob
--3932e853f2484be3956cac3d6b98de5e--