Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112726 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 70510 invoked from network); 3 Jan 2021 12:01:23 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jan 2021 12:01:23 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3C7CE1804D3 for ; Sun, 3 Jan 2021 03:37:04 -0800 (PST) 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-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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, 3 Jan 2021 03:37:03 -0800 (PST) Received: by mail-wm1-f49.google.com with SMTP id c124so14605843wma.5 for ; Sun, 03 Jan 2021 03:37:03 -0800 (PST) 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:to:from:message-id; bh=Rqk7ptAAJKfWxF1TRXO66U3uvX1fzmGZuG3YwM9PfiA=; b=sLeignodA8wdvhk5Ta8z2NBZ/wqNtvuBRcG1gJ6RuCaKAACotSLRllhYRtvJKSnoKR IlzQeEKnE9EMoQulfYtZ1DOTDFHDIeXShMWKpJpsbj2/zp1zjCW+7rj8QJ2H9zc09JA7 AVw5XBOuBB0ZRFgFYojjWJF1mc/bGyr/cX2+8Lee2IRuXg4nq4uT9cqQP5fxZoT6sEVQ JK844vVcdf+8pqTEGbOMO+ASJf6ktJLTSvD2MRlFb+nm+EBjb82udL3OXjmLf/DQ11WE YgNMDqJXgDT3RCKimhqkgzVGm+ka+lIdB092j2zANMnLlAdoswF+iveYYbBWYe5yGXNn NBoA== 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:to:from:message-id; bh=Rqk7ptAAJKfWxF1TRXO66U3uvX1fzmGZuG3YwM9PfiA=; b=kdYSpegekI/4MAruOSrtywpsgvuXOvl8T/WkUAkKnHdBcOc7mFWlk37syAdkI6s7A7 gMixcXdrveP5BL/hcvjKT2mkdk00Igl7NlPfLbVxq5t7p6UUsnUX0Nk1qIJeLNSdrk1V jYucGhLSvdviZ4zPfwSTS+rhroyhE8xUMEI/j7HpJQyLxSWqDnVBz0PPT8bG2gJU7io0 TZ4hbM9/B+jPXpTh8yFHIP2QLW1bG3GxxNfMq/RvxNeoPXFtA+og7Ghx2Zc8YwBNUOcu gzmU+suZuBV77yZ/3oH4DzlSVmPwWS8dx46mvGcYw2+/ZZRQGLZ6bykpXpVTDtt3aZm1 M+1A== X-Gm-Message-State: AOAM532Sp25rRP6XTEp+8x3ebybTaXJCMUdp3Vyk/P1MFMbrVsEyxd17 km+wZWMEJho2kvWzcHKq//ZO71ZeJxXoBg== X-Google-Smtp-Source: ABdhPJxMtIILQ6V3L+Az29zUf98+5qEIVqYr/MtybH55Fiqy+R75MnvJ/feLVEuClkMlLItZ334LTQ== X-Received: by 2002:a1c:9ac6:: with SMTP id c189mr22811571wme.137.1609673821839; Sun, 03 Jan 2021 03:37:01 -0800 (PST) Received: from [192.168.0.12] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.gmail.com with ESMTPSA id v20sm28475311wml.34.2021.01.03.03.37.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 03 Jan 2021 03:37:00 -0800 (PST) Date: Sun, 03 Jan 2021 11:37:01 +0000 User-Agent: K-9 Mail for Android In-Reply-To: <6f51556b-a566-45d2-939e-3d6c3441eb00@www.fastmail.com> References: <1d0abb04-4987-43a9-85bc-bccc3bd6be9a@www.fastmail.com> <03108284-740a-4a5d-130f-15b2e67e9df9@mabe.berlin> <459d7ff7-e553-dce9-7d43-c3b1e772e572@gmail.com> <7f4fe9ca-1c20-6f69-cef0-a9718af742a3@gmail.com> <30906866-1971-8395-05a0-fd78d054bb89@gmail.com> <0C621FEF-B76F-41F5-A5A8-E6F24D69DD3D@pmjones.io> <6f51556b-a566-45d2-939e-3d6c3441eb00@www.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: internals@lists.php.net Message-ID: Subject: Re: [PHP-DEV] Analysis of property visibility, immutability, and cloning proposals From: rowan.collins@gmail.com (Rowan Tommins) On 2 January 2021 21:25:08 GMT+00:00, Larry Garfield wrote: >If a stream is not seekable, then it would have to consume and destroy >$fp in the process (unset it)=2E So: > >[$line1, $fp2] =3D read_line($fp); >[$line2, $fp2] =3D read_line($fp); > >The second line would throw an error that $fp "has been consumed" or >something like that=2E But even that still creates potential for >spooky-action-at-a-distance if $fp was passed into a function, gets >read in that function, and then the parent call scope has a broken $fp >lying around=2E Yes, that is where "uniqueness attributes" come in: in Clean, that's basic= ally how I/O looks, but either of those scenarios would produce an error *a= t compile time*=2E The type system includes the constraint that the file ha= ndle must not be reachable from anywhere else when passed to the read_line = function, whether that's use of the same variable after the call, assignmen= t to an extra variable, capture by some other function, or storage in an ar= ray or record=2E The same constraint can be added to custom functions, allowing the compile= r to reuse the memory for, say, a large array that you're adding an item to= =2E So you still write the code as though it was immutable, and can reason = about it that way, but can also prove that it's safe to actually mutate it = in place=2E Similar things can be done, in a slightly different way, with Rust's owner= ship/lifetime system: the "borrow checker" proves that the manipulations yo= u're doing are free of "action at a distance" by prohibiting anything that = would create ambiguous "ownership"=2E Regards, --=20 Rowan Tommins [IMSoP]