Created
June 13, 2019 14:38
-
-
Save joseoliv/ff691b545d9006101d02c8081d5c5228 to your computer and use it in GitHub Desktop.
immutable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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