Skip to content

Instantly share code, notes, and snippets.

@joseoliv joseoliv/Feature.cyan
Last active Jun 13, 2019

Embed
What would you like to do?
feature
package metaobjectTest
@doc{*
Annotation 'feature' associates a value to an identifier.
It can be attached to fields, methods, method signatures, packages, and
programs. Other metaobjects, the compiler, and Cyan code (at runtime) can
search the list of features. At compilation time, use method getFeatureList
of any declaration (inside a metaobject code). At runtime, use method
'featureList' (for the current prototype) or 'featureList: String'
(for methods and fields) declared in prototype Any.
*}
@feature(proto, "Feature")
object Feature
@feature(aMethod, "run of Feature")
func run {
var Array<Tuple<key, String, value, Any>> list = self featureList;
assert "\"abc\"" removeQuotes == "abc";
type list[0] value
case String value {
assert list[0] key removeQuotes == "proto" &&
value removeQuotes == "Feature";
}
list = self featureList: "run";
type list[0] value
case String value {
assert list[0] key removeQuotes == "aMethod" &&
value removeQuotes == "run of Feature";
}
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.