Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122933 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 985FD1A009C for ; Thu, 4 Apr 2024 14:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712241001; bh=eCW2+kTU2I0cHH9GQ0IB0Ns7B36xF9l5lHI5s7UQJ4k=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=Fq0mWPLqeqxZHF4f93tdzq6h6e10qbwQh0AS4EYnl4YQTRxMYIdzsSCJ+WKJUpTO+ AD0PilTYxeEt9OViYe/LGr+pqbHOvpFmJszyc3c/Ka6UhG4eeX0mn/R5CrUpVX6N5t G/vLu6+D8mTc4wDe4wv6jwjXUxAoIRwj7M5yTKDtxnlEdz5ggIdRWBLgjqLuO9XrLR MKVi8bP0hASc4D1WESwh8s9ZNg3LVk4T6xFd1XsqgSv6VyrLxpUcdm2VRuLGGt199T tVcGaQQA3tvm3fsV9VpLAONEopygP77u8zy6wDBbEvZNOSt38mEgMWVpEXz3wiSdNV tw3l7CoF434KA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D88FF18057B for ; Thu, 4 Apr 2024 14:30:00 +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,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (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 ; Thu, 4 Apr 2024 14:30:00 +0000 (UTC) Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a5193f879easo59772166b.2 for ; Thu, 04 Apr 2024 07:29:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712240970; x=1712845770; darn=lists.php.net; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=eCW2+kTU2I0cHH9GQ0IB0Ns7B36xF9l5lHI5s7UQJ4k=; b=YggPmHGJsp7OjgCBkITYAetSE4WAKHbX5oLsFMggLMljVbXD6/23r8Pyx9WFKK2ppF Q5YgzZ2mt3574PSGAQvNBl+Lhp9hfX1nOQnw5QPYZwQ8pAgIPgVtcdpzXgxetjhwg6wi E/q/v8MnKqHgskwrKsmJEAR+m/WXMJ6+aRk7ZudQspmldgFTjeybB2N7P+aQx4Y+ao/J zCtv9W7QFZZHwX3/V+9ViEidZdJEE4KyW5TjP2Eigzbtfqje6OKTLrPKYaaolGzMPMPC qAYd5MOSqdjaFCExIKTsNVlhd01n2OY8yJDeaEJwiycEbd2wruvnuxedOeaGY1aHlhdf LaKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712240970; x=1712845770; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eCW2+kTU2I0cHH9GQ0IB0Ns7B36xF9l5lHI5s7UQJ4k=; b=tVCV34fBFk/LFgl9Pus4x1cYP8Viu7L1rWEzNtKc5BEVP/WYF5xBTnshKhxS+yz81c KWJ6rux137DsttIt9PxNDXqSCFW6Fv/T6cMsCLdkaQPYWOV+h/c+q9RJhWvqG4lJ6P2p Dcl+wM0SufchxgJ5nhLHikdh2onRBcANwkxNoNo49HmBBEI4k7vrgZT/bsEf2VTpe7oG Si4aM8lJVGhmqcX7z+IMAepK+GGm8HQx8crtuyJ3UcSdsXlPGB2QvEPRS3ApEYso+kMa IHFu+KSo5iM5j5UYgtPsj8GsLzDqgmVTDVx+F2k4muOhpVcYjD6liKU8vFoP4dq5Io/r /m6w== X-Forwarded-Encrypted: i=1; AJvYcCVpcnKEOM6IyZMx0SncYcjruGBNPo5bshY/MGK6Tv0Uj/45r1uUxhQnvTvJvTYd4JU2G9vphyECQDk2tfRlq2fo0PNaLL9nIA== X-Gm-Message-State: AOJu0Yw7wbIKYVLHXYFXn8i/jiA/tr6Tl4J6yu+bcx9FE7vwLPezmqCM p9BMin6fUq7xsPGywS2VLt9Z4aWmuyitYROXX+hf1mCcqNKoOpHmvwLKnlx0 X-Google-Smtp-Source: AGHT+IH3iL0ziHLBZESNJ2LWj1a8lGYxp85RJFe90kMNRQ+5yQt1oaBBwHnAQZ1U0KKWyAsI6lppxg== X-Received: by 2002:a17:907:728a:b0:a4e:9324:8df4 with SMTP id dt10-20020a170907728a00b00a4e93248df4mr2278616ejc.48.1712240969755; Thu, 04 Apr 2024 07:29:29 -0700 (PDT) Received: from smtpclient.apple ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id 22-20020a170906311600b00a4e8acaccb1sm3332222ejx.132.2024.04.04.07.29.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Apr 2024 07:29:29 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.500.171.1.1\)) Subject: Re: [PHP-DEV] RFC idea: using the void type to control maximum arity of user-defined functions In-Reply-To: Date: Thu, 4 Apr 2024 16:29:18 +0200 Cc: Pablo Rauzy , internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <7B32AF65-CA40-40F5-BA59-CB5180EC4D7F@gmail.com> References: <6299b649-c19b-4172-9632-2ef0a55d256d@uzy.me> To: Mark Trapp X-Mailer: Apple Mail (2.3774.500.171.1.1) From: claude.pache@gmail.com (Claude Pache) > Le 4 avr. 2024 =C3=A0 15:03, Mark Trapp a =C3=A9crit= : >=20 > On Thu, Apr 4, 2024 at 5:43=E2=80=AFAM Pablo Rauzy wrote: >=20 > 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]? >=20 > #[Nonvariadic] > function foo () {} > foo(42); // warning: foo() expects exactly 0 arguments, 1 given >=20 > I think the intent would be clearer and it would avoid introducing a = new syntax. >=20 Indeed, except that I think it should be better to have *by default* the = same behaviour between built-in functions and user-defined functions: ```php function foo() { } foo(42); // in PHP 8.x: Deprecated: foo() expects expects exactly 0 arguments, 1 = given // in PHP 9: Fatal error: foo() expects expects exactly 0 arguments, 1 = given ``` and, in case you want a variadic function: ```php #[Variadic] function foo() { } ``` Alternatively, we don=E2=80=99t really need to introduce a new = attribute, because one can just write: ```php function foo(...$args) { } ``` =E2=80=94Claude