Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Programming in ELENA
In this tutorial we will learn how to program in ELENA. Let's start!
Hello World -- Your First Program
We will create our first console application and learn how to print to the program console.
Let's start ELENA IDE (elide.exe in BIN sub folder)
To create our first program select: File - New - Project. In the open dialog we have to select: Project type – console; Namespace – example1; Target file name – example1 and press OK.
Next let’s create a source file: File – New – Source File
Before continue we have to save it: File – Save All (IDE will ask if the new module should be included into the project – press Yes).
We're halfway there.
Now type the following:
// A Hello World! program in ELENA. public program = [ system'console writeLine("Hello World"). ].
That's it. Now we can run it: Debug – Run.
The output will be:
Let's review our program:
The first line is a comment. The characters // convert the rest of the line to a comment.
Note: ELENA uses C-style comments as well: /*My comment block*/
Program entry point
To define our program entry point we have to create a code block with a public name program in the root namespace.
Note: square brackets define the code block (a closure without input parameters)
The program symbol will be executed on start up.
Note: Any exception raised in it will be caught automatically
Sending a message
Everything in ELENA is an object. To interact with it we have to send a message. The simplest (weak, i.e. without an explicit signature) message consists of an action and a parameter list.
The statement should be terminated by a dot.
In our example the action is writeLine and the parameter list consists of a single literal constant. The message target is system'console symbol (implementing input / output operations with a program console).
Any ELENA program or library consists of modules ( files with .NL extension ) containing classes and symbols. Every member of the module is referred by its fully qualified name which consists of namespace and a proper name separated by an apostrophe. The namespace itself may contain sub elements separated by apostrophes.
system'console refers to the symbol console declared in system module
Note: All source files (files with .L extension) located in the same folder are compiled into the corresponding module. A project file ( a file with .PRJ extension ) defines the root namespace and the output type (stand-alone executable, VM executable or a library). The project may produce several modules if it contains the files located in sub folders (the new module namespace consists of the root one and the folder relative path is split by apostrophes).
A literal string consists of zero or more characters enclosed in double quotes.
Note: ELENA supports both UTF8 and UTF16 literal constants