Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110940 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 40496 invoked from network); 11 Jul 2020 15:38:12 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Jul 2020 15:38:12 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B03811804C3 for ; Sat, 11 Jul 2020 07:29:50 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, 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-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) (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:29:50 -0700 (PDT) Received: by mail-qv1-f42.google.com with SMTP id h18so3942366qvl.3 for ; Sat, 11 Jul 2020 07:29:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=I8E6Hf0cCp1QDvvTLdO/OU6z+0jGF0Xv5J/fw7BxRMU=; b=CCExiixBSrsB4hcFlvUvkwglZQaPXUuMb4AH43KROBVi1gM1yFDsVE8RJ7rWbkBz+l s+fv7YmaKnagEo4VR53qnDHpd8IeEqw8hSfMGSAnZls4WK2TQMZYR1J8fedgDiTK1PC4 liHZjL9Jj+37geNVBvwXkgRN8RkJqr0q5nWLfQ6HBXK7xvCjcdU8tMelk1PiGPOmHJmk sGUiwHOuSA+gkNEgr1q8f+QTU4M87SIHLKXZmIW4P7rR+JH42nOxFzqRM9/AYWSb4Jyj VazcOfKhwZd33i/509ce8XbA7fkw+adRzzNt69BuDRpTFF14fhLZtI2PAIu6VKy7tc49 rpQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=I8E6Hf0cCp1QDvvTLdO/OU6z+0jGF0Xv5J/fw7BxRMU=; b=IFkcGY0YeVtW/0pY2eevQln03B8mE5D+GVaO8pNmGOAQTWMHKA02oVZlnAnu9ba0Fx jG3vgkeY4QwFxfMZ50/0z8vkoUfuSHaWTyNCr9a1FAgj4cCsBa2ht+6hk87kSD9Ue+bJ Sm0XmRa7uH9EkduGsqTzc6EWCAqgXJkscjLkVkkdwSUoRMi2BAO/t6zkPy7jWi57WvzB R3RiHb9N7adIxMeC6n+w5vaJlJflRzL9UYN5jUMA4fGTOVadwmEyd7JjR0XV+19tIzem x8Pxp9fkFoatx/d5FdN0XOmSxDrFrT9pxYJYimggxL+J2lWLAB075V1dWsUWDyJ91H6r OAtA== X-Gm-Message-State: AOAM53149WC/DNdxChRBSf9NU2/79ehOWANdy/0e5cdT18nh78qi/Mi9 ow88oAO994M9lfUSM5oqtBHVN5be7ec4/C0ZPgQ= X-Google-Smtp-Source: ABdhPJw7YBH2N43uvsTXrV9Btqv0BmV5JvHyaaYdGfgncRzNIh5Xchvf7dmDZFoWwRmeb1InHcyCR6xUP8ZohtiRmtw= X-Received: by 2002:a0c:8643:: with SMTP id p61mr73857418qva.43.1594477789608; Sat, 11 Jul 2020 07:29:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 11 Jul 2020 08:29:33 -0600 Message-ID: To: =?UTF-8?Q?Olle_H=C3=A4rstedt?= 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: cja987@gmail.com (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