What's it look like?
········································································································································································
GorillaScript has lots of similarities to C++ and VisualBasic, to name two. It uses braces for code blocks with an exception on single-line statements; it allows for global, shared, and local scoped variables, classes, functions, script entry-points, and a new feature called protocols. Protocols allow the programmer to enforce specific function guidelines on a set of functions so that any implementations of that protocol will use the same function prototypes. Its similar to virtual classes in C++, minus the classes.
Here is the most basic program, the Hello World program in GorillaScript:
script {
console:printf ("Hello, world!\n");
console:pause ();
} |
The first two lines "" and "" are comments, like C++, which are removed before compiling.
The third line opens up the default script entry-point. As GorillaScript is similar to C++ and VisualBasic in code structure, executable code must be placed in functions or entry-points, unlike Lua which runs the whole script as its entry-point. script is the keyword used to start this construct. An entry-point is the same as a function that takes no arguments and returns no values and is used when a script is "run" from the API.
console:printf ("Hello, world!\n");
console:pause (); |
The next line is a function call. It calls the function print inside the console group (or namespace in C++) with the text "Hello, World!\n" with a newline character at the end. As GorillaScript includes native conversion and concatenation on strings, adding "X is " and 1.23 will result in "X is 1.23" and therefore doesn't need the C++ printf style formatting functionality.
The second line then calls the console pause function which pauses the console until a key is pressed. This function calls the Windows "PAUSE" console function.
The last line, as you may have thought, closes the script entry-point function.
Here is the script in C++:
int main () {
printf ("Hello, world!\n");
system ("pause");
return false;
}
|
|