learn

There are two documents available: the Cyan Manual and the description of the Cyan Metaobject Protocol (MOP), the greatest innovation of the language.  For a simple way of starting using metaobjects, read section 3.3 of the last document. This section describes metaobject action_ati_dsa and similar ones. They are easy to use. The Cyan Metaobject Protocol is equivalent, in originality, to a PhD thesis. It is required by the Federal University of São Carlos (UFSCar) in order to get promoted to “Professor Titular” (title in Portuguese).

Most of the Cyan MOP is also described in the article The Cyan Language Metaobject Protocol (38 pages, submitted to a journal). This paper uses more up-to-date names for compilation phases than the full MOP description, although this will soon be updated.

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