Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@joseoliv
Created June 14, 2019 11:33
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/90a65d5a521c4bccf19ff6c1e9e12fb5 to your computer and use it in GitHub Desktop.
Save joseoliv/90a65d5a521c4bccf19ff6c1e9e12fb5 to your computer and use it in GitHub Desktop.
keepValue
package metaobjectTest
@doc{*
Annotation 'doc' can be attached to any declaration, including
the program and packages
This metaobject generates code that writes to a file the value
of a local or field that is parameter to the annotation.
In fact, the last five values of the variable are kept in the file,
which is specific to every variable. The
file is keepValue_varName.txt in the directory --tmp of a directory
whose name is the prototype in which the annotation is.
*}
object KeepValue
func run {
7 times: {
var Int r = Math randomInt;
// record the last five random numbers in the file
@keepValue(r);
}
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment