Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123549 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 65D471A009C for ; Fri, 7 Jun 2024 19:48:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1717789771; bh=Amzq5wSfFJNtvMbt2VZQLiqtH5Z2D16Wb1w1gHEPZAU=; h=Date:Subject:To:References:From:In-Reply-To:From; b=noN8pAhHGuHlhrFFFIILsULmEEvtglSN1AZ/mllUiHGhUFh6hf/30FQwLT5ZnCZi3 5JsnqlUTQn7K1neap+Byl95Vo32QXA5m1pi0A3mXcGy5Xby5ui2cFwWmFbnQ2y6zRS EKV3f9PO2+SEWuUVKjSrQgixILPUCya3IKGqruyjIabL+feBIfvZjqylgd/lfiBlxh d0tbCbfDVTMvnL3qS8J7Mp3yc0R6pDmXFzrstwbVtbXEi6lYZZKaCFZZxE08l8RnhT 2j2oSfc+D16ez/8Gn5dOpMrN8zPuZmmrwO8tIKDnXe+6C9q8IaZ3xKK7KuIP1Lzuvb PG68ZCfZqUDcA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 47CE6180B68 for ; Fri, 7 Jun 2024 19:49:31 +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, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, 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 smtp-bc0e.mail.infomaniak.ch (smtp-bc0e.mail.infomaniak.ch [45.157.188.14]) (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 ; Fri, 7 Jun 2024 19:49:30 +0000 (UTC) Received: from smtp-4-0000.mail.infomaniak.ch (smtp-4-0000.mail.infomaniak.ch [10.7.10.107]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4VwsFN01mtzPx8; Fri, 7 Jun 2024 21:48:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=processus.org; s=20231208; t=1717789703; bh=yOnsh3n9OjOiKfOoZphtpIYrpugqQTJc8FRSaNgx9FE=; h=Date:Subject:To:References:From:In-Reply-To:From; b=OzOeY1+qirQamIacs+/Kj6jaR+CbLYpS8cbxPbzWhlbyeMrJOuYRCL0KE1m8o4B6/ tVIMnynHsVLWnLjmcLAo6NHMvMMrXajzWb2A1Yo9S2462sd05LYUivIaSwyVijw6bO odCybgP6Ubnkg3DTAP7btO88hgyk859QB64ZIGOsMwFXtF/1fqhoztchX3C8dnii7T tiO72BC2+Kh3DrL7O1yEN3yeojnQli1eigE2z9rt5G+M6BW0gd7xQCX5Eg9YDFN+8G 2Mg0Df7FW519U/kpShpCrzmhuLeBhkt+AR0mKJeMPNx9GjnDYumpEld5IiEb2B2Tut E/xJpYTZPQ6Ew== Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4VwsFM3RGFzxcq; Fri, 7 Jun 2024 21:48:23 +0200 (CEST) Message-ID: Date: Fri, 7 Jun 2024 21:48:23 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] RFC proposal : "new" keyword shorthand To: Larry Garfield , php internals References: <652c1a66-6702-4009-a4a0-d2221df00f69@app.fastmail.com> Content-Language: fr-FR, en-US In-Reply-To: <652c1a66-6702-4009-a4a0-d2221df00f69@app.fastmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Infomaniak-Routing: alpha From: pierre-php@processus.org (Pierre) Le 07/06/2024 à 21:38, Larry Garfield a écrit : > On Fri, Jun 7, 2024, at 7:20 PM, Pierre wrote: > >> I sincerely do not want to see a new operator for replacing the "new" >> operator, because then we would have two different syntaxes which would >> be semantically equivalent. >> >> Creating a new object, in most API design, is not something you do very >> often, especially when working in a framework that does it for you >> (dependency injection, etc...). > This is not entirely true. Creating a new service object, yes, you rarely never do that yourself. Creating a new data object (value object, struct object, DTO, and a dozen other terms) is something that should happen more than most PHP developers currently do, because most of us have primitive obsession. (Or array obsession.) > > Consider attributes: Any time you want to have an object as the value for one of the arguments to an attribute, you need a "new." Any time you create a value object for a more strongly typed parameter than the horrid $options array, you'll be using "new." > > So I'm sympathetic to making that syntax easier, and would be OK with it if a workable syntax was found. But so far in this thread, a workable syntax has not been found. > > I agree it's not the greatest usability concern in PHP right now, though. > > --Larry Garfield I understand your point, but why replacing "new" which is basically an operator, with another operator ? I do agree with you that when you use value objects, you need it a lot, but I'd much prefer having a JS like value objects initializer syntax, such as `Point {x: 1, y: 2}` syntax than creating another way to call the constructor, which already has a mastered and comprehensive syntax which is simply `new`. As you said, it's not the greatest usability concern in PHP right now. Pierre