Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package metaobjectTest
Annotation 'prototypeCallOnly' should be attached to a method.
It assures that the method is only called with a prototype
as receiver. This is a replacement for 'static' methods
of Java/C++/C#. An annotated method cannot access
non-shared fields and it should be final (either
declared with 'final' or the prototype is final).
object PrototypeCallOnly
func run {
var PrototypeCallOnly p = PrototypeCallOnly();
// error if uncommented
// p at: 10;
// p unary;
PrototypeCallOnly at: 10;
PrototypeCallOnly unary;
final func at: Int n { value = n; }
final func unary { value = 0; }
shared var Int value = 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment