Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127448 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 0793A1A00BC for ; Sat, 24 May 2025 20:28:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748118379; bh=cxSuX3E9FsDIsaUUBgu6JKNTUcOsvrH2TdyB8LOw5n8=; h=Date:Subject:To:References:From:In-Reply-To:From; b=PLOGtvCh+8WriG/4NLCSxMPJDsHeBnQN3G1Vts6m0w7m7giPnow/NiSBEOwgL9rut weGAA6O6LuVETPMVyyL9l/CodM7jc/0vgLi1E+OQE8UyzORCNhSH5ZuYdMKKlEUmQ5 kwYS2tURS1VRPt9FgP2x6G8ef+APhkPPeq6FuVMTZ2y1MPmJ54AktGOa8j7i+RBtda M2xg3gDXyo9l8DBZD0oBJ/ikNke6ZWrvnAD3cqmuMlot0XV4lnUL5/KrCy+vGLGM0k W5OsHP89e7bardbSyqKJGC0Jk8/A2BwgT5MLS5wl09p7n8TJItoXYcVixX+nmMIbAH MG+CtMF9JW7hA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 61D67180053 for ; Sat, 24 May 2025 20:26:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.4 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 autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.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 ; Sat, 24 May 2025 20:26:18 +0000 (UTC) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-43ce71582e9so7934295e9.1 for ; Sat, 24 May 2025 13:28:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748118504; x=1748723304; darn=lists.php.net; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=LwKdN9wf6pdoe/dtJjJ1CQacKYYJVYFDGZ+j59xbxYs=; b=W6gA+nfqtBeEIuQInD29xP1MxmRnMCHCOY8p9bCL+pPJsWSwXCn28ayikTRnXl7Ou6 3r7+teWc1p2mDeL2mfLrsiSNZ5xYX6eSkHXQN2UpUj5oANMY8fkrzekn+d8AV0ZZmeIC aKukmXcysH+4R8vc7ZEDEWf19V13BoY2Z4+uXNXnP9rJrpONh8FXZ/yuUlApN+y9k6bO v4piVCSex7W6yDJL5Td4vezkYXqdg9+lIUj3M9jYhZNa0uTiBXOmGNcewgVKkNgJiv1/ IPsbbGXeMghBF/5eOOuV04Jpq5AhxbR3gNzu4ke4yAfhzsX8mQgqIXPQvZYeVXGpvFZW Sdbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748118504; x=1748723304; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LwKdN9wf6pdoe/dtJjJ1CQacKYYJVYFDGZ+j59xbxYs=; b=iLUW9JSOtqVFl406GfL7mQ19Zbh1vgsUYr2mRI3ggs9abvfoJGJ4IPhybgV6YRXlEx mT4ZV53E8fhAeM9xzgpMj5Ik1EtY6TG2bXHWfXUH8OBHpva0HIZ0JC5t2pgfGRiKR0PG zsoadOLHxg0qsQv+MfzDR2VPqcfvfZkWRub3zXxMNjE973lBqOhooOOgLEbQsrD4dV9m GpIjHJLAmNfggBZnw9B+OPkiidbfg8NGMW4gFE8anfrbJe0FNpYeoOgrFOBFR0ZaN5uw Hwk4Z4waboP2qTrc6E6n4K2Xm3C4NHjLNh1R5wolpvbGp3qyqdtMS1K6uyaj9UjXBugk CNCw== X-Gm-Message-State: AOJu0YzcbJUzI/oK4joBv6G8fYVtFEe90s9TKfTTnMYqKEQPUAXKGYDh PSeHU67lRq++dV1XjOdwNZo+m6XmcUFiT/7a5gw+sqQmZeJov2ZfN3FovqB2TA== X-Gm-Gg: ASbGncuuA9LhEFb22YoWbK3cRMqwhdwYNVXF1P6JyUJl5+UeZxFjroX8uthiAsaEpxh zj+OrXmAXqyfjiZ1+YsqzoXmm6BlO4QPNkZ5hbRaR3GpJ4hju9ZttFsq09GqxRwN7kkNVZo3Esi 4ZEO9XbGZRcq9dju+T9BB/o2Tqlken9bkYxiwvcAdcQRnmWZvJEC1U2dtr/Fbz3t/W6HbUBdK6g Cy8rPn6WvUHBUS2TBni9Gngp132+JgDCy/tD3SHHZqK5M711sR4I5dfi4WhT74+iglNPIvWzNbS 6SL0VeW7phMSN5or2Pc87drlIWQ99yQDboFIfj7Wug/7xcS8avy0wtFqVB84NVDy4iYenYcqsqV uM3wRTQwe8SeMZI3eYFbf X-Google-Smtp-Source: AGHT+IFdxmpPJRiz1f0MdUweCbMPC9x18JhKIQlShMAvvQ9hzVwLKi0k4TriiJ7OoJ+b+LgATMhgKA== X-Received: by 2002:a05:600c:a07:b0:448:e8c0:c778 with SMTP id 5b1f17b1804b1-44c92a5495cmr29652635e9.22.1748118504361; Sat, 24 May 2025 13:28:24 -0700 (PDT) Received: from [192.168.0.241] (178-119-85-231.access.telenet.be. [178.119.85.231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-447f73d4a3csm191886085e9.22.2025.05.24.13.28.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 24 May 2025 13:28:24 -0700 (PDT) Message-ID: <57f7ed3e-6bef-434d-83db-fd729ff43fc9@gmail.com> Date: Sat, 24 May 2025 22:28:23 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] Add num_available_processors To: internals@lists.php.net References: <8b76a3d4-4583-4849-a75f-00f645191247@gmail.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: dossche.niels@gmail.com (Niels Dossche) On 24/05/2025 21:24, Rob Landers wrote: > > > On Sat, May 24, 2025, at 19:42, Niels Dossche wrote: >> Hi >> >> In my opinion, the return type should not be nullable. >> Returning NULL when the platform (or PHP on that platform) doesn't support getting this information is an anti-pattern. >> Instead, availability of the necessary functionality should be checked at configure time and the function should be made conditionally available. >> That way, the return type can just be "int". >> >> Kind regards >> Niels >> > > I’m curious why you say this is an “anti pattern”? I do agree that it should return a number or throw. If you make the function unconditionally available, yet specifying the return type as ?int, then you give the false impression that it _can_ work even if your platform doesn't support it. Also: IMO new APIs should fail hard with an exception if they can't do their main task, that's our error "channel". > There are various error conditions it should throw (at least on Linux) so having it throw an exception when there isn’t a way to count any processors makes more sense than returning null. Throwing is indeed preferable. What are the error conditions on Linux? > > It could also be someone patching libc to get around per-core licensing too. I’ve seen the latter more often than the former.  I don't follow. In any case, if you run a monkey patched libc and you're breaking the consumer expectations of said libc, then you deserve getting it blown up in your face imo. Kind regards Niels