Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114150 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 19371 invoked from network); 25 Apr 2021 16:20:58 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Apr 2021 16:20:58 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E90AA1804F3 for ; Sun, 25 Apr 2021 09:24:47 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 25 Apr 2021 09:24:47 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 05BE31692 for ; Sun, 25 Apr 2021 12:24:45 -0400 (EDT) Received: from imap8 ([10.202.2.58]) by compute4.internal (MEProxy); Sun, 25 Apr 2021 12:24:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=7JJuIB Y5iR/5hXzeuF4NDsa1d/mQQ6COdNpUxLPSFFY=; b=rYfKmHToZYxwPXDVmgGMQZ vh37eI1i2uH7EFBYP3vJ80pU2GwupOKmr5wUmC0zPTapDP7lMCOiCil0QNmHfrZg jrZTdl3A3pyjxWzZpbWyD40m4r1OMZi0W6MbFqJ4OE/QqvwZOBg1Vdi63O4eT+Sj 7+6+PBDl9hf7pAj9GkRWGlk0rl0RHfgkrItl6JYBVB51ftaeOGfBw5DXU6X8hpoV +0BRhClmfokjJO02v8vLgR5cUGWk54bRM2ibZzfRUQeaEF4wCa12BBVlueuoI/g4 rQGz3lKy91mBjbelLsef1m+mKGg26S/GD7ueDmxBbnWYT+6kmXNsoFhQ8LOKXCow == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdduiedguddtfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepgeelgfekudeivddvteffueejffdthfejieevhefg ffekudevkedtvdelvddvffefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 397653A02D2; Sun, 25 Apr 2021 12:24:45 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-403-gbc3c488b23-fm-20210419.005-gbc3c488b Mime-Version: 1.0 Message-ID: In-Reply-To: <9B2BB3A2-0E47-436D-8002-D0662C481ADB@newclarity.net> References: <5b9f1500-615a-48f1-815f-1d48b327ef90@processus.org> <179049b1475.11134368b213512.254739612773841999@void.tn> <9B2BB3A2-0E47-436D-8002-D0662C481ADB@newclarity.net> Date: Sun, 25 Apr 2021 11:24:25 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC][Draft] Sealed Classes From: larry@garfieldtech.com ("Larry Garfield") On Sun, Apr 25, 2021, at 9:48 AM, Mike Schinkel wrote: > > A total function is a function that is defined over the entire domain of its inputs. For example, addition is a total function over integers, because for every possible pair of integers you pass to it there is a logical return value. However, square root is not a total function over integers because there are some integers you pass it for which there is not representable return value. (Negative numbers, unless you get into imaginary numbers which PHP doesn't support.) In those cases, you have to throw an exception or return an error code or similar. > > > > For a more typical PHP example, getUser(int $id) is not a total function, unless you have PHP_MAX_INT user objects defined in your database. If you pass an int that does not correspond to a defined user, you now have to deal with "user not found" error handling. getUser() is not a total function. getUsers(array $criteria), however, arguably is, because it's logical and reasonable to map all not-found cases to an empty array/collection, which doesn't require any special error handling. > Nothing I am about to write is meant to question the value of total > functions, but can you speak to the ramifications of a developer using > a library with a total function that returns miles or kilometers in > (say) version 2.0, along with the assumed guarantees of said function, > but then in version 3.0 the developer adds furlongs as a unit of > measure? > > Yes going from 2.0 to 3.0 is a breaking change per semver, but it > doesn't feel like it had to be had the application developer not made > the total function assumption. > > -Mike It would be a breaking change, because you're changing the definition of the problem space. Just as if you added a new option to an enum, or changed an Interface to have a method return iterable instead of array. If you change the definition of the data model, that's a breaking change and all bets are off anyway. Whether or not making it sealed in the first place was a good call is going to vary widely depending on the situation. They're really not appropriate for service objects, where by design you could have an infinite number of possible PaymentGateway objects. They're much more applicable for data objects that represent a finite number of business-relevant situations, where changing them means the problem space is changing *anyway* so changing code around the problem space is going to happen anyway. --Larry Garfield