A lot of mechanisms prevent common errors in Cyan:
- there cannot be any
return
statements inside anonymous functions - exception handling is made using anonymous functions and, therefore, there cannot be
return
statements inside either try blocks or catch clauses - there should be a space before and after
=
and the relational operators<
,<=
,>
,>=
,==
, and!=
- no parentheses are necessary for the
if
andwhile
expressions but the brackets are required if
statements may be nested but they should be correctly indented- no automatic conversion between basic types,
'var Int n = 1.0'
is illegal. This prevents a lot of errors caused by the combination of overloaded methods with automatic conversion - overloaded methods are clearly marked with keyword
overload
. A method overridden in a subprototype cannot be overloaded unless the superprototype method is marked withoverload
- constructors
init
andinit:
can only use a limited form of overloading that makes errors associated with overloading impossible - there are severe restrictions on the initialization of prototype fields making it very difficult to use a field before it is initialized. But in these rare cases, there will be a runtime error