Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104771 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 91970 invoked from network); 16 Mar 2019 12:21:21 -0000 Received: from unknown (HELO mail-wm1-f68.google.com) (209.85.128.68) by pb1.pair.com with SMTP; 16 Mar 2019 12:21:21 -0000 Received: by mail-wm1-f68.google.com with SMTP id e74so8597977wmg.3 for ; Sat, 16 Mar 2019 02:12:12 -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:to:from:message-id; bh=NWvZ3/LF/rtr4XXykIDdT5wF0s70wEYEUbCUOX+zbSA=; b=BHylQBB42q2C/LeJOM+Wp590d7v4Jzy/ecBuXGlcJw+DADwHk3/w4zpTM6+UeKifyF r3/stgh2Ovr3sOzco/8/Z/dhEyox+paF+wltbaI8VFpHi/QEgnFmj5dsOJA5KxYrUekj 6Kk+SaAAEKmD9FJtck0UzSpgIYRnxWQQhBsJW/WEJ1jgpgfc4usZ13JpOYEmE0S5n1GJ TKcnZEFVe3QclDmfuanWsXf7nDB2GlL/81HK5/XVT19FBVgKGsj/cQ+b4z2APFQVmQsE Vs0KUQHepylNGD0PdypRL4qGZpYM8WrbeUNjBnioI1YFtbQ+le2yaOZTD3XNvV+cdm8w G5hQ== 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=NWvZ3/LF/rtr4XXykIDdT5wF0s70wEYEUbCUOX+zbSA=; b=rog6bGqxQXyrCJVzWCdxgbG04l4yjWNdsrOQ0jPMNxATUPoWvOA5LRGggImPnWSwHy 3+xvHu85WoSxRXn/sfcf38LEJHwCRvDT/G76udboh+4MFiJv1oJ1Y215QbMF3bG+z47h A/kc10kYJiVMUv1GKW1Q7DXwgKvdI2IF7BQVeqclU4EJwK8r7sFLcxL3C//0ND2lDlFn lGjqC3x0n7DKxSsTPDV9dMYpqJSV2dg/6Glx0vJRhd2ypcKDBl0izlL/8Mar5e5/EB2d amdID7pcXUbV+6ABDcF9D9QZQi0QkCh/x7haaGhGH1AkTxUtG2+RP3EBIfFtFfEoAkV+ odPw== X-Gm-Message-State: APjAAAXd9qcLgvyH36+LPRBG955odMIiuTQw07csvlt76zNfmTVb5h0z HHBQey/nssNzk/Mr8icf7/25vsPF X-Google-Smtp-Source: APXvYqxA0IONqh2abizITvrHrFmCZ+uojnX270efREYToo4zQ1rg/UAmB04n9vzJh9SpRknKNyqxbA== X-Received: by 2002:a1c:cb86:: with SMTP id b128mr4640184wmg.46.1552727531255; Sat, 16 Mar 2019 02:12:11 -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 o10sm515862wrx.82.2019.03.16.02.12.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 16 Mar 2019 02:12:10 -0700 (PDT) Date: Sat, 16 Mar 2019 09:12:09 +0000 User-Agent: K-9 Mail for Android In-Reply-To: References: <5c8b20af.1c69fb81.c8b33.d2faSMTPIN_ADDED_MISSING@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: internals@lists.php.net Message-ID: <45B0854D-022A-481A-A7F7-A02EFDE7634C@gmail.com> Subject: Re: [PHP-DEV] [Proposal] Struct Data Types From: rowan.collins@gmail.com (Rowan Collins) On 15 March 2019 15:26:27 GMT+00:00, Nikita Popov wrote: >On Fri, Mar 15, 2019 at 4:16 PM Levi Morrison wrote: > >> Personally, I think pass by-value with copy-on-write semantics like >> arrays is the sweet spot=2E Mutability is fine if it is localized=2E >> > >If we introduce something like this, I think it is very important that >it >does not use the same property access syntax as ordinary objects, which >are >not copy-on-write=2E I do not want to be second guessing whether $x->y = =3D $z >is going to copy or not=2E The more I think about this, the less I agree with it=2E Firstly, copy-on-write is an implementation detail; the actual semantic we= 're talking about is by-value passing and assignment=2E So semantically, $x= ->y =3D $z would just be modifying local variable $x, as normal=2E It's act= ually doFoo($x) and $x2 =3D $x which cause the copying, and those look the = same for objects and arrays=2E Secondly, array syntax would prevent us from having any methods available = on structs=2E I suppose you could mix $foo['bar'] for property access and $= foo->doThing() for method calls, but if doThing() was allowed to modify the= object, you've lost the visual highlight of "may cause COW"=2E A pass-by-value struct would basically just be a way to reduce the overhea= d to both the programmer and the engine of sprinkling a codebase with the w= ord "clone"=2E Regards, --=20 Rowan Collins [IMSoP]