Chapter 3: Understanding Cyclone

Cyclone supports standard operators that are commonly adapted in programming languages domain. All operators supported are listed in the following sections.

3.2 Operators

Arithmetic Operators

The following operators can be applied to int and real types.

NameMeaningExample
+adda+b;
-minusa-b;
*multiplicationa*b;
/divisiona/b;
%remaindera%b;
**powera**b;
++post-incrementa++;
--post-decrementa--;

Pre-increment and pre-decrement operators are not available in Cyclone. Hence, ++a/--a; is illegal in current version of Cyclone.

In any situation, you can add (minus/multiply/divide) an integer to a real and Cyclone will automatically treat the result as a real number. For example, Cyclone returns a type checking error for the following code:

   int x=2;
   real y=1.234;
   int z=x+y;//illegal - type error

Boolean Operators

The following operators can be applied to bool types.

NameMeaningExample
&&anda && b;
||ora || b;
^xora ^ b;
!not/negation!a;
=>implicationa => b;

Relational Operators

The following operators can be applied to int and real types.

NameMeaningExample
> greater thana > b;
greater than or equal to a >= b;
< less thana < b;
less than or equal toa<=b;

Standard Operators

The following operators can be applied to int, real and bool types.

NameMeaningExample
== comparisona == b;
!=not equal toa != b;
+=plus equal toa+=b;
-=minus equal toa-=b;
*=multiply equal toa*=b;
/=divide equal toa/=b;
=assignmenta=b;

One Operator

Besides the operators mentioned above, Cyclone also provides a special operator called one operator. The one operator allows users to specify/express the meaning of exactly one of multiple conditions must be met. For example, the following code indicates that exactly one of the three conditions: a≥x,a≥y,a≥z must be met.

   one(a>=x,a>=y,a>=z);
The type of each condition must be a boolean expression. The one operator can also be used in a nested way. For example,
   one(a+b>t,t+a>s,one(a>=x,a>=y,a>=z));

 


@2020-2022 Hao Wu. All rights reserved. Last update: August 14, 2022