learn

The  only document available is the Cyan Manual.  This manual does not explain correctly the most important innovation of Cyan, which is its Metaobject Protocol (MOP). The explanation there is completely outdated. Read the articles instead.

The table below shows some metaobjects that are ready to use. There are around one hundred metaobjects in Cyan and they will be added to this table as soon as possible.

Name
(Clique to Example)
kindDescriptionUsage example
addBeforeMethoddemonstrationadd code before a method@addBeforeMethod(Proto, "run", "\"run called\" println;")
addCodeFromMetaobjectadd codewhen attached to a generic prototype, an annotation addCodeFromMetaobject can ask to an annotatiof addCodeToGenericPrototype attached to a generic parameter to supply code to be inserted in the generic prototype.@addCodeFromMetaobject
addCodeToGenericPrototypeadd codesee addCodeFromMetaobject@addCodeToGenericPrototype(String){* code *}

@addCodeToGenericPrototype(Id){* code to be added*}
addMethodTodemonstrationadd a method to a prototype. @addMethodTo(Proto, "run", "func run { }")
addToSetadd infoadd a pair (varName, value) to a map associated to the project. The pair can be accessed by other metaobjects@addToSet(secure, "yes")
annotadd infoadd information to instance variable, method, prototype, package, or program@annot("correct this")
rangecheckcheck if variable hold only values in the rangeInt@range(1, 12)
Char@range('a', 'z')
regexcheckcheck if a String variable only holds strings that match a regular expressionString@regex("[A-Z]+")
tainted and untaintedcheckcheck if a value of type tainted is assigned to a variable of type untainted. See the Checker Framework for more details. See also prototype TaintedToUntainted and the project file.String@tainted(sql) String@untainted(sql)
typechecksimilar C-language typedef, strong types for any typeInt@type(inBytes)
callRunMethodsadd codeadd code to call all methods called 'run' of prototypes of the current package@callRunMethods
callTestMethodsadd codeadd code to call all methods of the current prototype ending with 'Test'@callTestMethods
callUnaryMethodsadd codeadd code to call unary methods of the current prototype whose name match the pattern that is parameter@callUnaryMethods(".*Test")
changeFunctionForMethodreplace message passing, use in Cyan libraries onlyuse only in prototype Any. Create a anonymous function that represents a method@changeFunctionForMethod
func functionForMethod: String
checkCatchParametercheckwhether each parameter to a catch: selector has at least one 'eval:'
method, each of them accepting one parameter whose type is subprototype of CyException
@checkCatchParameter
catch: CyException e