Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104748 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 36754 invoked from network); 15 Mar 2019 18:25:46 -0000 Received: from unknown (HELO mail-lj1-f174.google.com) (209.85.208.174) by pb1.pair.com with SMTP; 15 Mar 2019 18:25:46 -0000 Received: by mail-lj1-f174.google.com with SMTP id y9so8000324ljk.6 for ; Fri, 15 Mar 2019 08:16:26 -0700 (PDT) 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=kgrKiNn9aqdn/ytbjXoccTihwfrpFAcOULCmgZbDk2w=; b=fJHWdSobyakrBF2yiRS8GaT639u5FUEzEY7oAYBzDQhJZdv3M2Md9k3WsrZLTs5t5e k3kdOBqeiRyIPVZkmkmnrCh2w6N1KseBVDsrl//5NyfRVAElb9TsT+iW+/h/HSBotLDH +Q32Ku3pao8sUeLc6riK+Vs5Vrhr7bRUnKrg6jwuXLzRAz4YwjkRMbaJRBdLTFzSgkuG orgafnwFbOFS1XHLjNFJHSfSCTQZtZzQsMxxTpV79IUL0HXxrwfNiVzaKElAI5IVQUur Ryj1c0R70oED0koM4uE1EI0Es+TfthwbMaQRjyqAwDYLsxzo5nhaMyv2Xfb4SfiMgm9E wYWA== X-Gm-Message-State: APjAAAULIDycN8oIQ/qKRcLis+XJeAQdrUaNBypXjJR5GATM6f3z2FYN rlN+tZYHvFxS3KuIFwRdTIDG0n/8+8Z88CjiDJw= X-Google-Smtp-Source: APXvYqxsfq1+ZwklkEGjXdx/kymqmE8e58vegCUTtpeOsqZREwv6hAi5ocxJDYVIWbE4Hqk2znKB42BIyEaQGC0bXQ8= X-Received: by 2002:a2e:2202:: with SMTP id i2mr2680574lji.170.1552662985295; Fri, 15 Mar 2019 08:16:25 -0700 (PDT) MIME-Version: 1.0 References: <5c8b20af.1c69fb81.c8b33.d2faSMTPIN_ADDED_MISSING@mx.google.com> In-Reply-To: <5c8b20af.1c69fb81.c8b33.d2faSMTPIN_ADDED_MISSING@mx.google.com> Date: Fri, 15 Mar 2019 09:16:08 -0600 Message-ID: To: Kenneth Ellis McCall Cc: internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [Proposal] Struct Data Types From: levim@php.net (Levi Morrison) Personally, I think pass by-value with copy-on-write semantics like arrays is the sweet spot. Mutability is fine if it is localized. I think having a no-constructor construction syntax is also a good idea. I've discussed it with a few people, but don't can't remember if it's ever been brought up on-list. Basically, the idea is to use a JSON-like syntax with the type-name in front, and I think it can be fine to use on regular classes that don't have a constructor too: struct Point2d { float $x; float $y; } $origin = Point2D { x: 0, y: 0 }; This syntax has no conflicts. We could also add an object literal syntax for creating ad-hoc stdClass objects like so: `$obj = { x: 1, y: 1}`. This has an ambiguity, but I believe I have solved the issue without too much trouble once before. I think structs, pass by-value with copy-on-write, and brace construction would go really well together.