Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122938 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 E37E91A009C for ; Thu, 4 Apr 2024 15:49:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712245778; bh=+bEvC5PJBw4vWXAcBp+5Rz+bRYlKurJeyE52bQ3Z+tY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=WKXLwVBZHpQZu0bdTrK8vkvnVdH2mQIVReGDxkv0/KVFn05xg80O0CwToDJgvTMeC ig5OmOEBAzvDO7VgbS6TavGw8I3HH4FqtnP6DKznksy49lWSMkbGZicH4qFlmFOBiG Xa3PuvBJiqD14rkhyHE4hzQ6prvn2bNq1ePDcJVZ1MyjIYXJtbBoN6UZzeW2+YJlGP k6Ie4wWDg3mLL3onPiefB0825zksh6otjxB/WTTRhM+PwpHWSRVMBW9W4VBLwy0enq 2fG5kqcbgwFp7lgY7QEvhNuN+wRVM0p28M8eQRGmnUo+oEKTbtJLVWFYW+VDc+lb55 C9xOPH9uaARFw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A7AEB180D2B for ; Thu, 4 Apr 2024 15:49:37 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 4 Apr 2024 15:49:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1712245746; bh=fYLPVvTRRXtuN5wb61dr4/X/OrvvAKYfWll+p6nU8nw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=FjLSz7mtDB7c3S1zcXVkz9RFdJL1KxeZvEf2gZCm5V3vwNFCcOENrg2uVPHncCj6w 7pF6T1RxwSoW803bjSbQDrMFtZpuTv8T7cEkPZSQAe5AFQeAgHnUmnHVEKPx+cmqR4 IE24IP853Q8oohfzsxJjjS0KYlAqlfuwsIKA7TmHIX/EJiWOdfXXmFYFch8gfJAQNg VkL/V7vA/5xKL2SdPrWOWxU3hhL/U47tYgIJ0z1UZKpdMvamKoggUYc4pN/WB4z2CK ewiFgsPnGAs2SLlIxlUM5gPhMpFdNQeo0w8akmoKj+D6vRqq1LWkVLGUWEb5UHpB6W FEmUBmVF/PnXw== Message-ID: <5969054f-1959-46a6-be5f-4de4550f2025@bastelstu.be> Date: Thu, 4 Apr 2024 17:49:03 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Subject: Re: [PHP-DEV] RFC idea: using the void type to control maximum arity of user-defined functions To: Vinicius Dias , Pablo Rauzy Cc: Mark Trapp , internals@lists.php.net References: <6299b649-c19b-4172-9632-2ef0a55d256d@uzy.me> <67221462-6c9f-48d7-8c59-e7262a744ff5@uzy.me> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 4/4/24 17:40, Vinicius Dias wrote: >> I like this concept, but instead of introducing a new syntax, have you >> considered leveraging attributes in the same way that PHP 8.3 >> introduced #[Override]? >> >> #[Nonvariadic] >> function foo () {} >> foo(42); // warning: foo() expects exactly 0 arguments, 1 given >> >> I think the intent would be clearer and it would avoid introducing a new syntax. >> > > I agree that using an attribute would be better for this case. I disagree with an attribute being the right choice here. In contrast to #[\Override], this proposal changes the behavior for the *caller* of the function and likely also requires adjustments in child classes when newly introduced in a parent class or interface. Thus it is part of the function's API and thus should be part of the regular signature and not the attribute-based metadata. Best regards Tim Düsterhus