Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127403 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 lists.php.net (Postfix) with ESMTPS id 3683B1A00BC for ; Mon, 19 May 2025 16:40:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1747672714; bh=/Wbt5vpPHm3dtDH2QQTGs2C4RuzPeN6glNuPI5d2kjs=; h=From:Date:Subject:Cc:To:From; b=FzCln7zbaytWW+0GeIbHIEUQx9KZ7GL20aEUNjV22uLRTV74BfLjW9f6NbemmZIF4 AbXDdcQoex/+CGLE3sLuZHlxYZUeLXgYuvb+CwBtdIucOBFCHvzZjqpwd540Dtzi55 hevw3jyUN8bdUDdi1wKfGU4vCLiCaOQNEh8Tfae/CcU9DkM+3jvUcMcJm2s2uzAxI7 QTVw2l/sUmNoBshZ7AcUoyOzdr1oYxDwoePOkex+rPjYWCALEiosQZIlXiWgcuSraX ExLHm8p84vjRxiSFZB85dYSQuUZRqU+t5fPKJWx8Ubfhxmq5XVTNJhdo+8pI8juERd N8l+vQN3yyV7g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7FECD180047 for ; Mon, 19 May 2025 16:38:33 +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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, RCVD_IN_BL_SPAMCOP_NET,SPF_HELO_NONE,SPF_PASS 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 outbound.qs.icloud.com (p-east3-cluster7-host5-snip4-2.eps.apple.com [57.103.84.173]) (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, 19 May 2025 16:38:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=garsi.de; s=sig1; bh=6LyINYrIRqRHgS0+JmmD25B90E5YIQUpFdIlO/zrOdY=; h=Content-Type:From:Mime-Version:Date:Subject:Message-Id:To:x-icloud-hme; b=jD4ABSmWvibAI9AR+nEz4Go2epoP0EPZ1ZeYNGO9ULh0clik90h6LnNzw/CGUuBf0 wdy88K4MV1Gdi1T62rE3tax8AMS4f93FXm1Q25bm353yOT0L9PWQMgjdzPlHPXoy7Z 4Ax8WVVwiBzhiGamh3ITd9xWM5pm0RnSzgSFw0nIazbAPsd77U7czNLjhxLWDa9Xl2 OEJxxXkFvWHZzolsOMsvskfxSuYV9uYqJzyTV/nwLFHP3Hr8xI3H45256hw4G4+RAE uJwiCS+2yzsGBpCNnk6179Ylp6oC2nY1ygZYWps01aTtIf6rF7jY/xdj2+HoyizPPj oEHRIXPeq93fg== Received: from outbound.qs.icloud.com (localhost [127.0.0.1]) by outbound.qs.icloud.com (Postfix) with ESMTPS id A45EB1800180; Mon, 19 May 2025 16:40:40 +0000 (UTC) Received: from smtpclient.apple (qs-asmtp-me-k8s.p00.prod.me.com [17.57.155.37]) by outbound.qs.icloud.com (Postfix) with ESMTPSA id 73936180010A; Mon, 19 May 2025 16:37:33 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (1.0) Date: Mon, 19 May 2025 18:37:21 +0200 Subject: Re: [PHP-DEV] Forced named parameters Message-ID: Cc: internals PHP To: Anton Smirnov X-Mailer: iPhone Mail (22E252) X-Proofpoint-GUID: 4PxBuuX9H57uFNZ1AjWguzTD133nZho2 X-Proofpoint-ORIG-GUID: 4PxBuuX9H57uFNZ1AjWguzTD133nZho2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-19_07,2025-05-16_03,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 adultscore=0 clxscore=1030 mlxlogscore=902 bulkscore=0 spamscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2503310001 definitions=main-2505190155 From: alwin@garsi.de (Yogarine) > Since PHP named args work similarly, borrowing syntax makes sense. It woul= d look like >=20 > function f(Type $pos1, Type $pos2, ...$v, Type $named1, Type $named2) >=20 > or without the variadic >=20 > function f(Type $pos1, Type $pos2, ..., Type $named1, Type $named2) Hi Anton, I really like the idea, but I wouldn't have the requirement implic= itly bound to the presence and position of a variadic parameter the same way= Python does. That kinda feels like a hack and doesn't follow the principle o= f least consternation. Moreover, what if I don't need a variadic parameter, but would like to decla= re that the function's interface requires named arguments (because I don't w= ant to be tied to locking parameters to specific positions). So instead I'd propose to implement this using an attribute (e.g. `#[Require= NamedArgs]`) instead. That way, you could even make it so that only specific= arguments are required to be named. It's also syntactically backwards compa= tible, so this feature wouldn't make your code break compatibility with olde= r versions of PHP, and could be made available in older PHP versions using s= tatic analysis. Alwin