IC differs from C in several ways. There are no pointers or structures, showing its Java heritage. Classes are declared like in Java, including inheritance. These take the place of structures in C. These classes can be defined to wrap native Java class, allowing IC methods to invoke native Java methods on Java objects from within the script code. Besides this, it also has some features associated with other languages. Functions (and methods) can be declared as macros (like in Lisp), which means the arguments passed are not evaluated at call time, but are substituted directly in at execution (like C #define macros). Functions and variables can be made "special" (like advise in Lisp). This means a different function will be invoked before or after a function is called, allowing manipulation of the arguments or the result. For variables, it means a new value assigned to the variable can be adjusted. Like in Perl, variables do not need to be typed. By default, any value can be added to any variable. However, typing is supported on a per-variable or globally enforced basis if desired. There are also minor syntax differences. For instance, the switch statement has been enhanced in a few ways. While it stll supports traditional C/java syntax, it has the following improvements:
- The variable switched on can be any type
- It has 'autobreak': if the case label is terminated with '::' instead of ':' it is the same as putting a break statement at the end.
- Besides equality, the cases can test for other relations, including <, <=, >=, >, and &. This is done by preceeding the case value with the operator - for instance:
switch (i) { case 8: // does if i == 8, then falls through into next case case >5:: // does if i > 5, then breaks case &1:: // executes if i is odd (and not already handled above) case < 0: // does if i < 0 default: // regular default statement }
|
|