Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110949 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 68168 invoked from network); 11 Jul 2020 17:59:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Jul 2020 17:59:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1888D180532 for ; Sat, 11 Jul 2020 09:50: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=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,MISSING_HEADERS, 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-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.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 09:50:46 -0700 (PDT) Received: by mail-wr1-f42.google.com with SMTP id k6so8969104wrn.3 for ; Sat, 11 Jul 2020 09:50:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:cc:from:message-id; bh=tJhXr8DUR4cYdKpcwq/+/NgwbCDt2C8T2+Yueu8TwnY=; b=tkZSxQZ8qwNz2qQvopJz3y8NqwwLigWK+2r5J+8srPwGzlTOn5pwOdfyvPvaCAWIbd udth/LtAnF5RWsYyOMNzBYUx1tdIwcpmcBvoLwhNrEnzqc7xWn+htzyVmg0SyuUJ4Ow3 CUNb8FQk4A6l6TmmWlaQlNj4NfyoNGOceCbywcM9vavrUALxHzBjkoZ6oUTi+z3+K/Uq 1zW0Yw/1FdC+h7l4pEXLqee4J/Z2kOaTwlk6M+puGq28G+76UEPwg8CrOWV63DbFAtPY PjtHJ8qRqKzZ8Cy/xENBHG+n8uRAaBGT32H9NFg1yskVYcro9/J3Jmbfg8xY7rLjGH3V S5TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:cc:from:message-id; bh=tJhXr8DUR4cYdKpcwq/+/NgwbCDt2C8T2+Yueu8TwnY=; b=LpNkfj219XfPXiq/CGQvWbqNxrqK7l6Jk0yMoEnLXmdydU0Tk64AVO+8nPthWRT8UA mBBvACHDR2HLsqEFFZcRGBRHopXe0ZwfRSLqCyuZjqaY0mjxrztT5AO/o1kF8b2cf4g8 6R+y2H9h1jBa4hcHL5SnTr0ypXEp4hI3PvH3ejj8KL32YH4FcSauHKE37sIsPKnnv/QT 2e1Ci17bXhwkPL3FGrehN4uRZdX6X0UC+dcFkzXbYhPvOikwJvzN6pAvUGLIFSrvCGia gEs/e96CA/gQoU2wKf2RuLdGZm1wno+e90gMGgcCS+PgOGQMqRj7ciF7Vdl1oFXxHMbL btaw== X-Gm-Message-State: AOAM5323M8XzHt14KoGRspz7VsuzNkPxrJ011RUv6ssBm9xxKX4OChVr Lirs0Ix2S92XRGOwSPJkFuuPotHv X-Google-Smtp-Source: ABdhPJzSzWG1Oxj5ujv18w4nZIOagyGh6frYwRkLq5k0qWTT2MxgmBMMF4g+cbvYvSA0j6ylFfR2wA== X-Received: by 2002:adf:e2c9:: with SMTP id d9mr72055303wrj.227.1594486243440; Sat, 11 Jul 2020 09:50:43 -0700 (PDT) Received: from [192.168.0.12] (cpc84253-brig22-2-0-cust114.3-3.cable.virginm.net. [81.108.141.115]) by smtp.gmail.com with ESMTPSA id v7sm15542699wrp.45.2020.07.11.09.50.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 11 Jul 2020 09:50:42 -0700 (PDT) Date: Sat, 11 Jul 2020 17:50:40 +0100 User-Agent: K-9 Mail for Android In-Reply-To: References: <6D442090-FA51-48A9-A07D-F27F5EF6FC0A@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable CC: internals@lists.php.net Message-ID: Subject: Re: [PHP-DEV] Possible RFC: UniqueInterface that throws exception at refcount > 1 From: rowan.collins@gmail.com (Rowan Tommins) On 11 July 2020 16:13:24 BST, "Olle H=C3=A4rstedt" wrote: >Yes, the point is to be limiting=2E :) Just like with immutability, you >apply certain limitations to avoid access abuse=2E Taken to extremes, this is the "secure a server by encasing it in concrete= " strategy - the hard part about designing useful limitations is not the pa= rts you want to make impossible, it's the parts you want to remain easy=2E There is a reason Rust has a whole set of mechanisms for managing ownershi= p, not just a single "mine/yours" split, because they allow the programmer = to express what they want to do with the object=2E >Regarding "freezing" an object, I actually already wrote about this in >a blog post, using dependency injection as a use-case, and a trait to >add a method to check the refcount: >http://olleharstedt=2Egithub=2Eio/php/2020/07/08/immutable-at-borrow=2Eht= ml The difference in my mind between freezing an object and tracking ownershi= p is that "frozen/unfrozen" would be an explicit state set on the object, n= ot a measurement that differs as it is used=2E So either the user says "fre= eze $object", and it is then immutable for the rest of the program, or some= point after construction implicitly freezes it with the same effect=2E This eliminates the dependence on tracking ownership or giving meaning to = the refcount, because no matter how you received the object, you must no lo= nger cause it to be mutated=2E=20 It also has much lower performance impact=2E Even the automatic form can p= robably be performed by the compiler - e=2Eg=2E if "new" was called in this= function, insert a call to "freeze" before the first time the object appea= rs as a function parameter Regards, --=20 Rowan Tommins [IMSoP]