Does cobra have special syntax for immutable types?
Posted: Fri Mar 22, 2013 7:31 am
In C# it is very verbose to create immutable type. Does Cobra have some shorter syntax?:)
Discussion about the Cobra programming language.
http://cobra-language.com/forums/
Charles wrote:It does not. Do you have suggestions?
hopscc wrote:What type of immutability are you looking for ?
Kinds of Immutability
For MP perhaps better to default to immutable objects and have some syntax to explicitly relax that....
var name = ['abc', 'python', 'cobra']
Charles wrote:What about collections? If I create a list like so:var name = ['abc', 'python', 'cobra']
And I want the list to be immutable, what idiom/syntax should we use?
var name = readonly ['abc', 'python', 'cobra']
var name = const ['abc', 'python', 'cobra']
#No opinion on the exact keyword - for 'readonly' could use 'const' or 'immutable'
# augment/provide a clarifying isname declaration
var name is readonly = ['abc', 'python', 'cobra']
# or
var name = ['abc', 'python', 'cobra'] to readonly
var name = ['abc', 'python', 'cobra'] to mutable # or 'variable'/'nonconst'/'var',....
var name = ['abc', 'python', 'cobra'] to * # '*' for mutable, '|' for immutable say - read as fuzzy vs rigid