Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101909 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14670 invoked from network); 23 Feb 2018 14:26:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Feb 2018 14:26:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=marijic.silvio@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=marijic.silvio@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.175 as permitted sender) X-PHP-List-Original-Sender: marijic.silvio@gmail.com X-Host-Fingerprint: 209.85.216.175 mail-qt0-f175.google.com Received: from [209.85.216.175] ([209.85.216.175:44941] helo=mail-qt0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 61/85-01511-584209A5 for ; Fri, 23 Feb 2018 09:26:14 -0500 Received: by mail-qt0-f175.google.com with SMTP id g60so10694583qtd.11 for ; Fri, 23 Feb 2018 06:26:13 -0800 (PST) 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; bh=XfTW05NVlnufjQ6923+CfQyR6OWX+StADKQKYYs4D2A=; b=X/bVNmZ6/7MG0ilCD2i2ZsnANBMlPWZJyAqVEIN97u9XLUlO2Bz18K5hWe39hk1GiJ tDxbQA4DvKuVUJzynNm6hCMQLtG4KLSjpVk55V53nw6prRyEZPhqxlnLvimZ7Na0DWw1 HA8Fd69w76VJgU2LJxTFzGhQbqrjK4NWc5AtFu+areSOuLk8xzujSDB6KKYDzfOo57/b 3UENDj66u4BPUYwnUEvKVE9LGLxfm1jY9z34BruN6FqoR53xwwgxH2uNviW+1FQgs4vA TIwUDlhoB8sxD5D1Ft5bhVKFP9VLvYWIT9culhmOauUlfFDf5CxD1KwwG2infRfmKOnn QryQ== 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; bh=XfTW05NVlnufjQ6923+CfQyR6OWX+StADKQKYYs4D2A=; b=KdESOpJKp9h7rmAQNE8CJaVKkgSnMlzRI9QxxetsnG93aZM1Hv3apfVpNavZ42G+3d XgsvnsFs+DXGdmJxqD7LXQrvs4cSDFwpHfFwXudWQPVo0lWmZoNGVu/RdmQb78ZHYjTv TdeY1ACjQoxtzWVsCA2UzhbpBHecUzeAV4bC0LiykAHaaLpRu2GrGc+nSQvwGdgaJ9KF wZqy35nfY85zZ3hlDyTekbBdAYCN7j/FoabkgsGQRukWOdUY9dS++vdLbjZaf61jmBCo dnEXcKM7fmOvMphfF19gXhmj/aFPVIuyrCiDRCCBdMtzzxGiajKGomfVlJjOZy5ePrO/ aVYg== X-Gm-Message-State: APf1xPDi76kQ21OyjvApqk4t0XTI8Pq9pSX+v2YheR0P+ZEhkiKv7pOj 6KTei8NuN5rCvtFn1N/FRo/ugK8YKVdeClIS2Lk= X-Google-Smtp-Source: AG47ELujYHdSM9+L+UBRK41s8gunb0TlzDmEM5liYmBEe4rMp7Sl6GSSMkr5EdrCgHlRXlVM7Inefh01jOhULGKL/64= X-Received: by 10.237.32.226 with SMTP id 89mr2993069qtb.150.1519395971206; Fri, 23 Feb 2018 06:26:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.33.133 with HTTP; Fri, 23 Feb 2018 06:26:10 -0800 (PST) In-Reply-To: <2B23EFFB-21C3-49E4-9000-B2E0F97E93A2@gmail.com> References: <2B23EFFB-21C3-49E4-9000-B2E0F97E93A2@gmail.com> Date: Fri, 23 Feb 2018 15:26:10 +0100 Message-ID: To: Paul Jones Cc: PHP Internals List Content-Type: multipart/alternative; boundary="94eb2c0cb4de23113e0565e1f128" Subject: Re: [PHP-DEV][RFC][DISCUSSION] Immutability From: marijic.silvio@gmail.com (=?UTF-8?Q?Silvio_Mariji=C4=87?=) --94eb2c0cb4de23113e0565e1f128 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks Paul, I do have rough idea how to go about arrays possibly without recursive scan, I have to try couple of things, it could work if some checks are moved to zval level. For now it is in the future scope unless I manage to handle the within week or two. First two proposals are valid points. Regarding disabling constructor, that would fail as soon as you try to write properties in constructor since object is already "locked". Best regards and thanks for proposals. 2018-02-23 15:08 GMT+01:00 Paul Jones : > Hi Silvio, > > I like the RFC. > > * * * > > I would like to see arrays allowed as immutable properties. > > In I wrote that arrays are > "probably not practical in most situations" because you have to > "recursively scan through array properties to make sure that they contain > only immutable values". > > However, I think if the scanning happens at the C level it is not such a > burden. John Boehr implemented it for the immutable ServerRequest object = in > ext-request and it has worked well. > > If you do allow arrays, they would have to follow the same rules as the > immutable object. > > Alternatively, perhaps an ImmutableArrayObject would be a good addition o= r > followup to the RFC. > > * * * > > Some further points to harden the implementation: > > - I see that resources and references are disallowed (which is good). If > you have not already done so, you may wish to disallow streams as well. > > - You might want to disable setting of undefined public properties, so > that you cannot "add" mutable public properties to the immutable object. > > - Disable the constructor after it has been called, so the object cannot > be "re-constructed" in place. > > * * * > > That's all I can think of for now. Thanks for putting this together. > > > -- > Paul M. Jones > pmjones@pmjones.io > http://paul-m-jones.com > > Modernizing Legacy Applications in PHP > https://leanpub.com/mlaphp > > Solving the N+1 Problem in PHP > https://leanpub.com/sn1php > > > > --=20 Silvio Mariji=C4=87 Software Engineer SMSGlobal --94eb2c0cb4de23113e0565e1f128--