Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101912 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23601 invoked from network); 23 Feb 2018 16:03:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Feb 2018 16:03:50 -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.178 as permitted sender) X-PHP-List-Original-Sender: marijic.silvio@gmail.com X-Host-Fingerprint: 209.85.216.178 mail-qt0-f178.google.com Received: from [209.85.216.178] ([209.85.216.178:39427] helo=mail-qt0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 82/E6-01511-46B309A5 for ; Fri, 23 Feb 2018 11:03:50 -0500 Received: by mail-qt0-f178.google.com with SMTP id f4so11091866qtj.6 for ; Fri, 23 Feb 2018 08:03:48 -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=4eMrUWY8RzydG35A1oxJBaq5UeN2KHiy5S78uEsWDUI=; b=Mg20uu760pFGtM1flwSzg9YLTcMYfi3GxJxPkdofoTxU9BKKq/BnztufUKueGqYg8u wgC58OtQGzIZWcol6tIAc9K6DxQMAA3brr1NL6WVSfB/wtvMeOHiWSJNHdM1/L9nXox6 cUsYS7DJERlTafjjAbk6e6K9Epuzvz7+g39yKpVODziW67kWUhRoYS7B502libO01u+m xFWxnoYpvEwWxkEMLC0am3Pjk3CYeoSbltHn1O4mDGDb6FKSx9OFhL2CkFSGmnyMNcLT KNKsm/VhOADaL647yJNj8hyYvkaxuBt/OR0+IW/ScWQkfa9GPWz6DhcyZrGYmcuZZRag CSYA== 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=4eMrUWY8RzydG35A1oxJBaq5UeN2KHiy5S78uEsWDUI=; b=nq/vvRfH/umnIkqQgwMTTnK9QRs1D9PDs5SpvkS9JisO03TctrmZ2+1isu54rYKCUI 7ZSieyOGIHacyBm2rUszp7OBh5iyUegOcULBlRt4EBBF7ILjgqFh8uANJZWJ27lT/7k1 lFU8P/He/XU5njq/tJjVbf0eiN75xZmLZiPbW8AYFINn5jtDTyO8C//rHoLgfJjSk+zY VqfwO8NqTPNBTq4RA7pnq2ciVBwdOdRYsMkQfLkJJcRTzEpAfiiYHWc0AA9y4GkmvmrS R4Fm8jO7phfJZt5z+wZ4tlbkLlZS7qO8wQOG7OFqk+EvDQv4bvbOkeiQJ8KotoIQcDNd inRQ== X-Gm-Message-State: APf1xPAgMff+muE0z6FY4pu3zPm4qAMR+YVyBKEPIjbF6mrahCcWf2x8 aEA2hN6ZtSipgSsNVaaUFKLXws0dZhs8mcJldiA= X-Google-Smtp-Source: AG47ELvpT8sYWjSHdubycAxi0DIWD0yK4V7ulHQto31hJVGe3/cu74qipBgV0Cw/d8d2c+fQdFVvgW6XIlkZgb6Zgow= X-Received: by 10.200.38.217 with SMTP id 25mr3196924qtp.163.1519401826173; Fri, 23 Feb 2018 08:03:46 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.33.133 with HTTP; Fri, 23 Feb 2018 08:03:45 -0800 (PST) In-Reply-To: References: <2B23EFFB-21C3-49E4-9000-B2E0F97E93A2@gmail.com> Date: Fri, 23 Feb 2018 17:03:45 +0100 Message-ID: To: Niklas Keller Cc: Paul Jones , PHP Internals List Content-Type: multipart/alternative; boundary="001a114256501ed2270565e34e17" Subject: Re: [PHP-DEV][RFC][DISCUSSION] Immutability From: marijic.silvio@gmail.com (=?UTF-8?Q?Silvio_Mariji=C4=87?=) --001a114256501ed2270565e34e17 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Niklas, Problem with checking array on assignment is that it could be N dimensions deep and one would have perform check for each item in each dimension for mutable values which could have some performance implications. Regarding constructor call, upon first initialization of object, you are allowed to assign values to properties, after constructor is executed, object is locked. If you try to call again constructor on the same object it would fail as soon as execution reaches first assignment statement because object was already marked as locked. I agree that it would be better to pass by value but I am not sure how would that impact the way we currently manage objects in object store. Best regards, 2018-02-23 15:47 GMT+01:00 Niklas Keller : > Hey, > > > 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. > > What's the issue with a one-time runtime check on assignment? > > > 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". > > You lock the object after the constructor has been called, not > afterwards. If you don't do that, your objects won't be immutable. > > I like the RFC, but generally I think value objects that are passed > by-value instead of by-reference are the better way to solve the > problem. > > Regards, Niklas > --=20 Silvio Mariji=C4=87 Software Engineer SMSGlobal --001a114256501ed2270565e34e17--