Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104751 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 45139 invoked from network); 15 Mar 2019 18:47:32 -0000 Received: from unknown (HELO mail-io1-f48.google.com) (209.85.166.48) by pb1.pair.com with SMTP; 15 Mar 2019 18:47:32 -0000 Received: by mail-io1-f48.google.com with SMTP id u12so8580616iop.11 for ; Fri, 15 Mar 2019 08:38:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fcG/PWYl3n6RQDTfTMhbNBlKZzZrWAmmiCrdVRUGdCg=; b=aAUuij2sqiXl3hAflyf/cb1t3ywLGBO62/lds8gSCsBk2PHxwt8tWdCrj9NEJlNtog qPT3epG49B10ta9LggJfmgUyVqnhx8XMZqnc9yMsRwjaeJg4AfVY07sGoDPoIMo+qyyz o/sFmsIGdM4PB1xeNoxEdxIX3wYp8ULR5lsmB20OpqkGuIO3adAWqDrEiIBezwl4fnlv qcLuGHxYoE5UZ9pxX7K3UL75/t+5mzlfy7EfyfrQJ6zvHgYT4fwD4afmdteVpqoemtZB ve96Fk1TFNJUSAIk9eJzqwmlU1/jzmuiWxshEqnJsvb4lnwj3O8H0teQMWiqt+b8Ixyk GjFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fcG/PWYl3n6RQDTfTMhbNBlKZzZrWAmmiCrdVRUGdCg=; b=hQRG207SLRSFjeLeL1HulfFhONVhwCA2wTUz/6+P7GvEzipwc/PhIRg8sl4KWbVstw WstKV36ggagW9vvYIzPe2qnXprCeplBWcRN5FM4aeBMndFaeGCPBmBPmTtS8SxghKGi9 Math+Dd3lmH4Lx7IV9s5DXSl+qdAAS8d6BdO2FezlvEZ281ZVaBHUWpa9i8m6FPMqjiP AujDh4tJxYt8K0m83/qdLEZ6iCKbv2XOU272CzIqrw3nzWTwLPMuBK30mLWpkwK53r90 vOgUKKcA5ENlSPfQ8GN+QbAcivNvjTyiiBVsm0e2KODx47oTHtfmPQrh120f0kPSLQVQ Tugw== X-Gm-Message-State: APjAAAU8SqDCTMmbAIC0ipIX6Ac/9WwJW+Ik4aoZ1FHWLfcRw7pAQMjo e/deuPiTtpyro4x9sqFAXD9kxhyb1TDCT/Poxdk= X-Google-Smtp-Source: APXvYqzodOh0r88Wq+XhfiVShTtrZlgznse0lxUi2NYeA16ZBMxNjOZr1U9huq+vZQHUUUmfgcoGslntI2GH5wjg4vQ= X-Received: by 2002:a6b:ee02:: with SMTP id i2mr2528697ioh.219.1552664292222; Fri, 15 Mar 2019 08:38:12 -0700 (PDT) MIME-Version: 1.0 References: <5c8b20af.1c69fb81.c8b33.d2faSMTPIN_ADDED_MISSING@mx.google.com> In-Reply-To: Date: Fri, 15 Mar 2019 15:38:01 +0000 Message-ID: To: Nikita Popov Cc: Levi Morrison , Kenneth Ellis McCall , internals Content-Type: multipart/alternative; boundary="00000000000097ec64058423d33f" Subject: Re: [PHP-DEV] [Proposal] Struct Data Types From: rowan.collins@gmail.com (Rowan Collins) --00000000000097ec64058423d33f Content-Type: text/plain; charset="UTF-8" On Fri, 15 Mar 2019 at 15:26, Nikita Popov wrote: > 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. I do not want to be second guessing whether $x->y = $z > is going to copy or not. Possibly such struct types should indeed use the > array access syntax, because array access is generally copy-on-write (the > exception being ArrayAccess objects). > The problem I see with using array-access syntax is that it implicitly encourages dynamic property access, because the argument is syntactically a string, not an identifier. $foo['bar'] = 42; $foo['bar' . '_2'] = 69; // looks just the same vs $foo->bar = 42; $foo->{ 'bar' . '_2' } = 69; // clearly doing something unusual I see your point about making the COW more obvious, but I think it should also be obvious that you're working with a structured type, not a collection. We need to invent some more punctuation to use! ;) Regards, -- Rowan Collins [IMSoP] --00000000000097ec64058423d33f--