Re: [RFC] Property write visibility

From: Date: Mon, 29 Jun 2020 10:52:27 +0000
Subject: Re: [RFC] Property write visibility
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-110772@lists.php.net to get a copy of this message
man. 29. jun. 2020 kl. 12:06 skrev Deleu <deleugyn@gmail.com>: > Are there any other languages that have a similar syntax? Has any other language syntax been considered The only one I could find that matches is Swift: public private(set) var numberOfEdits = 0 https://docs.swift.org/swift-book/LanguageGuide/AccessControl.html#ID18 Beyond that there are some notable related examples: C# public readonly Color Black = new Color(0, 0, 0); The semantics of readonly is closer to what we refer to as immutable here: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/classes#readonly-fields If you want other semantics in C# you'll need to resort to Accessors: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/classes#accessors Rust: // This field can be read (but not written) by super. #[readonly] pub(super) readable: i32, Essentially a feature using "attributes": https://docs.rs/readonly/0.1.6/readonly/ -- Best André Rømcke

« previous php.internals (#110772) next »