China Stuff

China Photos


.    IC
.   .    Looks like C
.   .    Differs from C
.   .    Scripting features
.   .    Functions
.   .    Using
.   .    Download
.   .    Comparisons
.   .    Has
.   .    Missing
.    Regexps
.    catchall.php
.    Elisp
.    Tetrii
.    sudoku
.    Mail aliases
.    AQI history
.    Subway
.    SchoolSite
.    Host change
.    freehostingweb

Harry Potter

Contrarian Ultimate




Site Map

Kinds of Functions

There are lots of options to consider when declaring a function. First, a function can be scoped everywhere, or limited to use within a particular class (function vs. method).

Second, both functions and methods can be declared to be macros. A macro is similar to a function, but has 2 major differences. First, the arguments are not evaluated when the function is called, but evaluated each time they are references in the macro, like in C #define macros. This means, for instance, if a macro is called with an argument of "a++" then a will be incremented each time the argument it is assigned to is referenced in the macro. The other difference is that the macro is executed in the same calling frame as the original code, so local variables available within the calling function are also in scope from within the macro.

There are also 3 different ways functions can be written. These are:

  • Defined: Written in IC itself. These definitions look just like a function definition in C.

  • External: Written in Java, but with knowledge of the IC API. These are passed the IC symbol table object and can access the symbols and arguments using IC methods.

  • Builtin: Also written in Java, but these are objects that do not understand IC, or even know that they are being called from outside the normal Java environment

There are some limitations on functions. Overloaded functions are not defined (maybe they should be?), so it is not possible to make objects identical to Java classes. In addition, not all primitive data types have been defined (currently only int, string, and array), so only methods with those primitives and user-defined classes as arguments can be defined.

Special Functions and Variables
Functions (including methods and macros) can be made "special", which means much the same as "advised" does in Lisp: a designated function is called before and/or after the function itself, and the arguments or return value can be examined and changed, if desired. All types of functions/methods/macros can be advised.

Similarly, variables can be made special as well. A special variable is one with an associated function that is called whenever the variable is assigned a new value. As with special functions, the value can be viewed and adjusted in the handler function, and the variable is set to the adjusted value.

Call or Send Us Mail!

or send email to
image of email address

(sorry, the email addresses
that used to be here have
been disabled due to spam