current stable: 0.99.6 unstable: cvs (0.99.7) |
|||||||||||||||||||||||||||||||||||||||||||||
|
TypesFerite 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: numberThis 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:
stringStrings 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.
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. arrayArray'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.
objectObjects 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.
voidThe 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.
|
||||||||||||||||||||||||||||||||||||||||||||
ferite et al © 2000-2004, Chris Ross |