Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123552 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 CC3701A009C for ; Fri, 7 Jun 2024 21:48:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1717796950; bh=3EAEULUMbGXT/KQui5xOv2mOwWlL3Pt1tJae1uvbTr4=; h=In-Reply-To:References:Date:From:To:Subject:From; b=ZaKgun4oj1AiydQ+X2U0pNHUUZaV87QmM20cEtICAfdWprkbKjpBAKTQHdjX+AC3O 3l1WxYhm+3uTbNjv/3qLqvdsAW6KEMBjXFom572s8lsQ7ieD4yoIjlVFmNUtpUyvdx 5b3Qnr5cPzCHwcJZ/3khIwC1J6OH/5/RfbHMMvqiNV+VjOyOq4XYeGGW6GWhtOdGv7 M5RWBlfa3JvHEDfK/aOvZysHDsEgMvw2vo/ZrpjjAjdMVhZdZp4KUQl9hmYjoa1sda U+CKxm2ZoKgMC0w9dg6AEjFaX9dhQlczSSevEyyvSc8lwMAxlTvms/zDP0bAE6OxWV oFOnWzwnwZsiQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 85694180080 for ; Fri, 7 Jun 2024 21:49:09 +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,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from wfhigh1-smtp.messagingengine.com (wfhigh1-smtp.messagingengine.com [64.147.123.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, 7 Jun 2024 21:49:08 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.west.internal (Postfix) with ESMTP id 58D8218000EF for ; Fri, 7 Jun 2024 17:48:01 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Fri, 07 Jun 2024 17:48:01 -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=1717796880; x=1717883280; bh=uaMMrrWqavCsBo3Li080P SQwi0nYyetZNZWtFp2XO14=; b=FGhFYvlgWaSWaf0IyYYaISJCCqFHwgehZe/TJ 3Hcsc1/i0phIyYd79HdeFDv4ajKua6HjMzOFq69S8boryRAJuiIBrhDU/JiCuI3W ibevJZaKQIPrsj+dFnU6615qvPb3BnPnXwTJOaIa2vD4kkzfSWdKTmzt/7ZC6xtk dy0yhit3at+lp5bW480GywgrWodSsagdT0+Kq9ZDOQtexiDnx1m0ZaH+qB/APjxJ 9wps+JIOFf1KnNvSAzpHwaF4wpIp9VTG3zCRv/4CUTB63XtsWoe3LDcI7a3lU/Zl 440N6thobhHXpfuKM6k2+LPu8Ig2OnLc1yIEK89ACTTri/Xkw== 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=1717796880; x= 1717883280; bh=uaMMrrWqavCsBo3Li080PSQwi0nYyetZNZWtFp2XO14=; b=k LzzWmkZh6cXDF0T20kOOeiAnMF2PN2IW3AgLmsF2gDLil1OHjg2UWtUwKYTMNK4r ffHXNYA4OIRB1YOtS1WOijx/6lSnWU71z7u7LamCMTcfO4DX4RTCR72b2yG1ZyDA 2Uo3GrISeTaoW4TaIbOlQFXfgF+IO0fKvB4l/N44fTJfpmMrPotQyEdAMiR3GwXf 03YdDDw/mPAxalqbCgxuoC0qo1kS9WZ0Z39ZJGnXzfKd6QvBsUt1pcYzfCrMaNUN UEjTWTamXpDYmDNAYwrOipdi7AaegYuZWZqSrd5IWxe6zzpEloVVMjrydwqqCehy Dm+BfIP0suj4JRcyWja0A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedtvddgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepffffffejffdugfegvedviedttedvgfejffefffej leefjeetveehgefhhfdvgfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id A605F1700096; Fri, 7 Jun 2024 17:48:00 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-497-g97f96844c-fm-20240526.001-g97f96844 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <73390f84-4c4d-4a48-a173-24ad424e0d2e@app.fastmail.com> In-Reply-To: References: <652c1a66-6702-4009-a4a0-d2221df00f69@app.fastmail.com> Date: Fri, 07 Jun 2024 21:47:40 +0000 To: "php internals" Subject: Re: [PHP-DEV] RFC proposal : "new" keyword shorthand Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Fri, Jun 7, 2024, at 9:34 PM, Erick de Azevedo Lima wrote: > Hi all. > >> Em sex., 7 de jun. de 2024 =C3=A0s 17:53, Pierre escreveu: >> I do agree with you that when you use value objects, you need it a lo= t,=20 >> but I'd much prefer having a JS like value objects initializer syntax= ,=20 >> such as `Point {x: 1, y: 2}` syntax than creating another way to call=20 >> the constructor, which already has a mastered and comprehensive synta= x=20 >> which is simply `new`. > > I also think that `new `(4 chars, if we count the blank space) is shor= t=20 > enough. > But a JS-like syntax that's already known for representing objects=20 > could be used. > I'm sympathetic to something like this (changing the OP examples): > > class A { > public function b() { > echo "I'm B"; > } > } > > A::{}->b(); > > > class Foo { > public function __construct( > public string $name > ) {} > } > > class Bar { > public function __construct( > public Foo $foo > ) {} > } > > $bar =3D Bar::{ Foo::{ "I'm foo in bar" } }; > echo $bar->foo->name; > > > #[AttributeOverrides([ > AttributeOverride::{ > name: "id", > column: Column::{ name: "guest_id", type: "integer", length:=20 > 140 } > }, > AttributeOverride::{ > name: "name", > column: Column::{ name: "guest_name", nullable: false, unique:=20 > true, length: 240 } > }] > )] > > > #[AttributeOverrides([ > AttributeOverride::{ > name: "id", > column: Column::{ name: "guest_id", type: "integer", length:=20 > 140 } > }, > AttributeOverride::{ > name: "name", > column: Column::{ name: "guest_name", nullable: false, unique:=20 > true, length: 240 } > }] > )] > > -- > Erick We already have named arguments, which gives nearly the same syntax. Wr= iting directly to properties like that makes no sense in a language that= has class-private properties and internal constructors. It's fine in R= ust or Go that don't have internal constructors, but it's just not a goo= d fit in a PHP-like language. And new Foo(a: 'A", b: 'B") is already perfectly readable and self-docum= enting. Yet another constructor-invoke syntax on top of that would offe= r nothing. --Larry Garfield