| news | about | documentation | files | project | forums |
E is a scripting language designed for games and event driven applications. It utilizes a strict type system for performance in both script execution performance as well as the overhead involved in calling functions between the C++ application and the virtual machine. While a generic C like function binding system is available, one of the main features of the E API is the ease in binding classes and functionality to the virtual machine. It utilizes template meta programming to requires very little explicit information to bind classes and functions to it.
It has support for all integer and floating point types including native strings. Conversion is automatic for all types including classes that have cast overloads. There are 12 types in E.
char
short
int
byte
word
dword
real
real8
string
class
function
event- Classes are user-defined compound objects like C++.
- Functions are user-defined procedures that take and return arguments.
- Events are a type of function that does not return any values and may be called in a series of calls to other implementations of the same event.All your favourites rolled into one!
E incorporates various elements from different programming and scripting languages. Most of the structure of E is designed around C++ while giving higher level functionality such as automatic type conversion and automatic garbage collection.
Here is the equivalent of the Hello, world! console application in C++ written and explained in E.
-- main.e
-- e™ script example-*
Function: main
Parameters: int, string[]
Returns: int
Attributes: entry (is entry point), global (to entire virtual machine, not just the script itself)
*-
decl (entry, global)
main (int argc, string[] argv) int
{
-- declares a string called world that is assigned the value "world"
string world = “world”
-- calls the print function in the console group with the string values added
console:print (“Hello, “ + world + “!”)
-- returns with the value 0
return 0
}As mentioned, E provides an event system that can be used global events as well as on object instances. Due to the way it is implemented, it does not intrude on the structure of the environment or the objects involved and all events are procedurally created and raised. This means that an object can have several events applied to it without it even knowing about events in the first place.
-- events.e
-- e™ script example-*
Event: onEnterFrame
Parameters: real
*-
event onEnterFrame (real deltaTime) : on (game:instance ().frameNum % 2 == 1)
{
-- event body
return
}-*
Event: onEnterFrame for game:actor class
Parameters: real
*-
event onEnterFrame for game:actor (real deltaTime) : on (this.getType == game:type_player)
{
-- class event body
return
}
-- entry point
main () null
{
-- raises all global implementations of onEnterFrame (real)
raise onEnterFrame (1.0)
-- raises all game:actor implementations of onEnterFrame (real)
game:actor ^ a = game:instance ().getActor ("player1")
raise a.onEnterFrame (1.0)
}
hosted by www.sourceforge.net