Skip to content

Instantly share code, notes, and snippets.

Created June 24, 2019 04:46
What would you like to do?
package metaobjectTest
Annotation 'readOnly' should be attached to a method.
It assures that there is no assignment to either
shared or non-shared fields inside the method.
Note that does not guarantee that the method does
not change the receiver fields (self fields). These
can be changed by methods called by the attached method:
func unary {
// otherMethod can change a field
self otherMethod;
// can change a field
// because it can keep a reference to
// the current self
aField set: 0;
// self is passed as parameter and
// a method that change a field can
// be called
aField add: self;
object ReadOnly
func run {
at: 10;
func at: Int n {
// error if uncommented
//value = n;
// error if uncommented
//sharedValue = n;
var Int value = 0;
shared var Int sharedValue = 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment