man. 29. jun. 2020 kl. 12:06 skrev Deleu <deleu...@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

Reply via email to