Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108571 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 32705 invoked from network); 14 Feb 2020 15:08:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Feb 2020 15:08:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 687421804DA for ; Fri, 14 Feb 2020 05:23:08 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.9 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-vk1-f174.google.com (mail-vk1-f174.google.com [209.85.221.174]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 14 Feb 2020 05:23:07 -0800 (PST) Received: by mail-vk1-f174.google.com with SMTP id i78so2585978vke.0 for ; Fri, 14 Feb 2020 05:23:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=P+FaQjPefnZSy3R3uHnB5kvVwoRy4HEkEOAHey96MXY=; b=CNyUdPXKpr8IhAXQU4I7dpdYxExbpUCIjdKb1ySSowGa1o2VxkQBo6mspTJd0GS74+ SNZme7O0uMhpebjYldr7fxXLkSbIi578xHnBM5ZS/maNtgiBeBybZEm5nj/W8T7haW/q WzFxw947HxwJ8UOaUUeNPP+a4S09IvvTMCLyOKIoz3AuNorhayygMsNET4YZkdmOhMvj 0lCVF51+JntM4f1FsyKEN4w2Uhw4szjcGAXUBC5L1sFAsomCAtzIjTbIxDmOn7/TTmpt erAOeA2K2VdfKS8P3XRTVxg3b3eM8MjxnvAEpV37DVGx6moezp+2n8qTcBoW0NxOdj9k zHSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=P+FaQjPefnZSy3R3uHnB5kvVwoRy4HEkEOAHey96MXY=; b=B+jrA7L4J46haZgJV+nBtrFwlEiVh+VStzsQs0hzdg31WmZ+XGo7tH1xdwvsQT3e/N +vvP2LedCsTd4hfHpRLyllCzlyLPWWWmigeGizMFp1vza0zq+e5odIPP4BvX4HGQRCFH 9b0/2QdfrFWOLEM0hcpGvawNrGQcMUc1cvU5Q5iVI8wK49kNsPm5HNaSE6oaE/7ILEo7 d8PI0fUZd3RJeoVqZl3M5VQ3LSSGfbSkF0wrk8IKHReTcMZUTYgBZYsprLPzyNd25bjN OXpibjmTxX+Uia7ovRIsNLZvwkvc8/Mn9bHVSIgp411tBhr331Gy4KOkvYrdOrOhZ6Ii JFtw== X-Gm-Message-State: APjAAAU2akG0u/Et2+RXHlzxgVizUoPqVol/l5jQa46EPlM7eSf5GOtO CsezPPRuzay8S+Qw4l7CvZd8A6f6l4j0x0nbVrfWRUxN1A0= X-Google-Smtp-Source: APXvYqxuI4LCvuqgGqJqObPL/VbKfzZ0t6Ul5twYw5zFog7/fShK4eJ/4WwJYIb5WhLbilXiseYPzx2no7imjov/6vc= X-Received: by 2002:a1f:ac57:: with SMTP id v84mr1649236vke.90.1581686584585; Fri, 14 Feb 2020 05:23:04 -0800 (PST) MIME-Version: 1.0 Date: Fri, 14 Feb 2020 14:22:53 +0100 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000053393059e891b28" Subject: [RFC] [PROPOSAL] Immutable/final/readonly properties From: kocsismate90@gmail.com (=?UTF-8?B?TcOhdMOpIEtvY3Npcw==?=) --000000000000053393059e891b28 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Internals, I'd like to propose the idea of adding support for immutable/final/readonly properties in PHP 8. My plan is to add a new immutable/final/readonly (the name is up for debate) property modifier to the language so that these kind of properties could only be initialized but not modified afterwards. Unlike how final properties in Java work, I think it would be beneficial to allow lazy initialization of these properties after object construction have taken place. Currently, I'm in favour of using final or readonly, but not yet very sure. I'll write a proper RFC in the following days/week. My clear intent with final properties is to pave the road for immutable objects for which I have a POC pull request open (but I haven't pushed all my work yet). So far, my biggest question (apart from the name) have been how non-typed properties should behave: as they are implicitly initialized to null if they don't have an explicit default value (while typed properties remain uninitialized), further modifications would be impossible to do on them - which would make non-typed final properties almost useless. Nikita suggested to just avoid their initialization, but I'd be curious about other ideas as well. Thanks, M=C3=A1t=C3=A9 Kocsis --000000000000053393059e891b28--