38 lines
638 B
Plaintext
38 lines
638 B
Plaintext
struct _box {
|
|
private ptr = 0
|
|
def get() int { return 0 }
|
|
def set() int { return 0 }
|
|
def free() int { return 0 }
|
|
}
|
|
|
|
ground {
|
|
extern "_box"
|
|
}
|
|
|
|
/*
|
|
Shared mutable object. Use with caution - may cause impurities!
|
|
*/
|
|
struct Box[T] {
|
|
|
|
private box = new _box
|
|
|
|
def get() T {
|
|
retval = new T
|
|
ground { callmethod &self &box !get &retval }
|
|
return retval
|
|
}
|
|
|
|
def set(T in) int {
|
|
ground { callmethod &self &box !set $in &retval }
|
|
return 0
|
|
}
|
|
|
|
def free() int {
|
|
ground { callmethod &self &box !free &retval }
|
|
return 0
|
|
}
|
|
|
|
constructor() {}
|
|
|
|
}
|