4. CyML Language Specification¶
This document specifies the CyML language, an extended Cython subset supported.
5. CyML Language Specification¶
This document specifies the CyML language, an extended Cython subset supported.
5.1. Cython file types¶
The implementation files, carrying a
.pyxsuffix.
5.2. Basic Types¶
The following basic types are supported
boolintfloatdoublestring
5.3. Complex Types¶
The following complex types are supported
arraylistdatetime
5.4. Conditional Statements¶
IF
IF/Else
IF/ElseIf/Else
The ELIF and ELSE clauses are optional. An IF statement can appear
anywhere that a normal statement or declaration can appear
5.5. Integer For Loops¶
CyML recognises the usual Python for-in-range integer loop pattern:
for i in range(n):
...
for i in range(f,n):
...
for i in range(f,n, s):
...
Like other Python looping statements, break and continue may be used in the body, without else clause statement.
5.6. While Loop¶
Like Python While loop
5.7. Function¶
Parameters with declaration
Default value is possible
5.8. Return Statement¶
A function needs to return the same data type.
The following code is valid:
def fibonacci(int n):
if n <= 2:
return 1
else:
return fibonacci(n-1)+fibonacci(n-2)
5.9. Call functions¶
Call to CyML functions are supported if the function
is accessible on the module
is accessible from import statement
5.10. Operators¶
Assignment
Assign |
|
Unary operators
UAdd |
|
USub |
|
Binary operators
Add |
|
Sub |
|
Mult |
|
Div |
|
Pow |
|
Mod |
|
BitOr |
|
BitAnd |
|
Augmented assign statements
AugAdd |
|
AugSub |
|
AugMult |
|
AugDiv |
|
Comparison Operators
Eq |
|
NotEq |
|
Lt |
|
LtE |
|
Gt |
|
GtE |
|
Bool Operators
&& |
|
|| |
|
5.11. Array routines¶
`` `` |
Return a new array of given shape and type, without initializing entries. |
`` `` |
Return a new array of given shape and type, filled with ones. |
`` `` |
Return a new array of given shape and type, filled with zeros. |
5.12. Mathematical functions¶
Trigonometric functions
|
Trigonometric sine, element-wise. |
|
Cosine elementwise. |
|
Compute tangent element-wise. |
|
Inverse sine, element-wise. |
|
Trigonometric inverse cosine, element-wise. |
|
Trigonometric inverse tangent, element-wise. |
Hyperbolic functions
|
Hyperbolic sine, element-wise. |
|
Hyperbolic cosine, element-wise. |
|
Compute hyperbolic tangent element-wise. |