current stable:
cvs (0.99.7)
  Home / News
  The Team

  Source Tarball
  CVS Web View
  Misc. Files

The Manual
  Download [html]
  Download [pdf]
  View Online
  Download [html]
  View Online
  Script Examples

Developer Guide
  Download [html]
  Download [pdf]
  View Online
Ferite C API
  Download [html]
  View Online

Open Source Approved

SourceForge Logo - browse the Keyword Map of

[previous] Comments[up][toc]Variables [next]


Ferite is a semi-strongly typed language. This means, unlike in Perl or php, you have declare variables that have to be used and what type they are. Ferite has a number of types within it's system. The simple types are number (automatically switches between integer or real number system), string, array, object and void, and are described below:


This type encapsulates all natural and real numbers within the 64bit IEEE specification. Ferite will automatically handle issues regarding overflow and conversion. Several things have to be said about the number type:

  • All numbers start out as C longs (64bit integers). When the value goes over the maximum value allowed for long the type will switch over to a C double.

  • Comparisons can be made between numbers but it should be noted that once a number has internally become a double, equality comparisons are likely to give unexpected results. To add this and make things slightly more reasonble, when doubles are being compared there is a slight amount of tolerance involved which means that they do not need to be identical but very very close in vaule.

    number someValue = 10;
    number someOtherValue = 1.21;
    number newValue = someValue + someOtherValue;


Strings are specified using double quote ("") and can contain control characters. The control characters are defined as in C by use of \'s. Anything that ferite recognises as an evaluable construct within the string will be evaulated.

It is possible to access individual characters within the strings using square bracket notation (described later on).

You can reference other variables or even place small expressions within the strings such that they get evaulated at runtime. This allows for the complicated construction of strings to be less painful. To reference a variable you simply prefix it's name with a dollar symbol '$' (It should be noted that the string representation for the variable will be used. For objects that contain a toString() method, the method will be called and it's return value used.). To reference an expresion you use a dollar symbol followed by a set of curly braces '{ }' with the expression placed between them. For example, the following code will print out "Hello World" and then print out 2.

    string test = "Hello";
    Console.println( "$test World" );
    Console.println( "${(1 + 1)}" );

Strings can also be defined using single quotes (''), these differ from the above notation because everything within the single quotes is quoted. This means that the above variable substitution and escape sequences will not work.


Array's provide a method of storing a collection of information and accessing it randomly. The contents of the array either be accessed by means of a hash key or indexed by means of a number. A variable of any type can be placed within an array - this means that you can mix numbers, strings, objects, and even other arrays. This is a very useful feature as it allows you to group together likewise data on the fly. Arrays are accessed using the "[ ]" notation as in other languages, this is discussed later under the Index Operator section.

The standard way of creating arrays is to declare a variable and then modify it using various different operations. Most of the time this is fine albeit a bit overkill. To make array creation slighly easier there is a notation that can be used. You simply create the array by using a pair of '[' ']' brackets and placing a comma seperated list of values between them.

    array a = [ 1, 2, 3 ]; // Declare an array 'a' and initialise it to have 3 elements


Objects are instances of classes. When first declared they point to the null object (this allows the user to check to see whether the object has been instantiated). To create an instance please see the new operator. The null object is always within a script and can be referenced using the keyword null.

    object o = null;
    object o2 = new SomeObject();


The void type is similar to Perl's and php's type when first delcared. Anything can be assigned to them, but after having something assigned to them, the void type is removed and the variable then becomes whatever type was assigned to it. e.g. If a void type is created and has a number assigned to it, it can't then have a string or object assigned to it as it has become a number.

It is important to note that the only thing that can't be assigned to a variable of type void is a function. You can assign namespaces and closses to variables of type void and then use them as normal.

    void v = null; // v is now an object pointing to null
    void v2 = 42; // v2 is now a number with the value 42
    void v3 = SomeNamespace; // v3 points to SomeNamespace

[previous] Comments[up][toc]Variables [next]
ferite et al © 2000-2004, Chris Ross