Skip to content

Instantly share code, notes, and snippets.

@joseoliv
Created June 13, 2019 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joseoliv/ff691b545d9006101d02c8081d5c5228 to your computer and use it in GitHub Desktop.
Save joseoliv/ff691b545d9006101d02c8081d5c5228 to your computer and use it in GitHub Desktop.
immutable
package metaobjectTest
@doc{*
Annotation 'immutable' should be attached to a prototype. It checks
whether the prototype is immutable (no field can change its value
after the object creation). Then an immutable prototype should
only be inherit by immutable prototypes and all of its fields
should be declared with 'let' and their types should be
immutable. All basic types (Int, String, ...), Any, and Nil
are immutable.
*}
@immutable
object Immutable
func run {
}
let String name = "Immutable";
// error if uncommented, 'var' is not allowed
// var Int Max = 100;
// error if uncommented, 'Array<Int>' is not immutable
// let Array<Int> array;
// ok
let ImArray<Int> iarray;
let Nil nil;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment