Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package metaobjectTest
Annotations of this metaobject should be attached to a prototype.
The attached DSL code is made in Myan, which supports interpreted Cyan
within parameterless methods declared with 'func':
func afti_codeToAdd {
// interpreted Cyan code
According to the method name, the Cyan code is interpreted in phase
afti or dsa. Methods of interfaces
can be implemented. To better understand this, see the documentation
for action_afti_dsa.
/* A method missing with two keywords and two parameters p1 and p2
is replaced by
p1 ++ p2 ++ p1
func dsa_missingKeywordMethod {
var String sss0 = ((message getkeywordParameterList get: 0)
getExprList get: 0) asString;
var String sss1 = ((message getkeywordParameterList get: 1)
getExprList get: 0) asString;
return [. sss0 ++ " ++ " ++ sss1 ++ " ++ " ++ sss0, "cyan.lang", "String" .];
// a custom error message for unary message passings
// ending with 'Test'
func dsa_missingUnaryMethod {
var String name = unarySymbol getSymbolString;
if name endsWith: "Test" {
metaobject addError: "Methods ending with 'Test' have not been implemented yet";
object OnMethodMissing
func run {
var ssss = self use: "abc" append: 0;
printexpr ssss;
assert ssss == "abc0abc";
// if uncommented, a compilation error with a custom error message
// self selfTest;
// if uncommented, a regular compilation error
// self alienMethod;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment