Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110942 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 44211 invoked from network); 11 Jul 2020 15:47:48 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Jul 2020 15:47:48 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C48FC1804B5 for ; Sat, 11 Jul 2020 07:39:29 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (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 ; Sat, 11 Jul 2020 07:39:29 -0700 (PDT) Received: by mail-ed1-f52.google.com with SMTP id a1so1468489edt.10 for ; Sat, 11 Jul 2020 07:39:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=cfatYe7yV7e7SSUrFTPNKmHy+BYkNRm+j7JqF6ghdQs=; b=BazBozn1BIkIi3cly3Tt67B11CriwvN2o8VZfX66Vonnt2DxW7s9YUnYebn18FeqIl 4AO9Xdvlm/NcX/BCcdHl0hajAtunz4o6HiijnST43VKMRU4XhZDVYHP99YxmrjN9FQSN enwwA5aLnPrHfFi+0TluM2ompzb9h4UYH16GkIOq/Vne+iff8OVFcjW0198AdLFZf648 e0wBKinIaNY1DVlwsWWlEfb61mrjZ3LPA7Zl7nGOwBQHvJ0E0IemzH9+4yC2Xx0Ee1mx kOxKVzHhAX7w5imFmbKnO59CEzO97tmGDtn4x8q/0tH/XC49hC6Zulil+xpuwvIBeW2z uO1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=cfatYe7yV7e7SSUrFTPNKmHy+BYkNRm+j7JqF6ghdQs=; b=G4Q7vuc7/SBMnnBPe+zaeYh3m/RMlee6qgztDNUG2EL/saRuFUXDv3/Ulu+pEN0uAJ N/UY/LIV2BYK4l9Kkm2uiKQT1fBHBDsvLbowlThSgTOCnyK67hcYLFf+uXneWAWLfTCd u4qOZF3Z/BHl7iFxI7F+G9DPbBvfaOwVgUzNkm15AZs6jini3+KIWeQI960pbkGG4bUx wT7wWKeelM6eGhoM8STRDVtK+npW9X7Lwlt+oeq922G7GcR2jMiDxIbydMtQknFSRb1d S89q4pIYQ3AXSa1oUx4TCCbz3/LtzaBYtZk+0BFf9XHuxFAIt1dPwFTNyz7IyPYqcJJq yIgw== X-Gm-Message-State: AOAM530L1fzUQhM/OqhSWl95TqRQqVlejBPyOwsYDRukO4N/40umT3lf xF4f2ylnZYZUmY3KF1qU3PyU0mDRKYIjo3ztQX8= X-Google-Smtp-Source: ABdhPJz96RiM2oZfJTFa3bS8tUS7TJCVDgO8j+QHsAS+CFwgUPAMbrIvoC5tCqahnmIu3XSmBJKyCR8201WpqSBzphQ= X-Received: by 2002:aa7:d2c9:: with SMTP id k9mr72539288edr.98.1594478368019; Sat, 11 Jul 2020 07:39:28 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a54:3091:0:0:0:0:0 with HTTP; Sat, 11 Jul 2020 07:39:27 -0700 (PDT) In-Reply-To: References: Date: Sat, 11 Jul 2020 14:39:27 +0000 Message-ID: To: Chuck Adams Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Possible RFC: UniqueInterface that throws exception at refcount > 1 From: olleharstedt@gmail.com (=?UTF-8?Q?Olle_H=C3=A4rstedt?=) Thanks for your answers! Yes, it would be a dynamic uniqueness system, kind of. Another more flexible alternative would be to add magic methods at refcount =3D 1 and refcount > 1, possibly __owned() and __shared(int $refcount), for classes that implement a TrackReferencesInterface or similar. But this would need to do ~0 performance hit if not used, don't know if possible. Olle 2020-07-11 14:29 GMT, Chuck Adams : > On Sat, Jul 11, 2020 at 8:06 AM Olle H=C3=A4rstedt > wrote: >> >> Dear internals, >> >> I'd like to discuss the concept of ownership in PHP, from the point of >> view of a new interface UniqueInterface (or SplUniqueInterface or >> something), which will throw a UniqueException if refcount > 1. >> >> Use-case: Mutable objects that cannot be shared (without (deep) cloning)= . > > I don't think you want to do this on refcount, since that would > prevent even passing it to another function or using it in any number > of expressions. What would make more sense to me would be hooking > into copy-on-write, which would also be a slightly less hot code path > than reference counting (but still a pretty critical one). > > It almost sounds like a uniqueness type, something well beyond the > capabilities of PHP's type system (and most others). > > --c >