|
|
|
|
Quick Links
Understanding XL
In depth
Other projects
|
XLR: Extensible Language and Runtime
|
A simple Hello World program in XL can be written as follows:
import IO = XL.UI.CONSOLE IO.Writeln "Hello World" Like most scripting languages, and unlike most compiled languages (C, C++, Ada), XL programs can contain instructions at the top-level. For short programs, this reduces the amount of syntactic noise. For larger programs, this can be used for global initializations. The program displays Hello World on the console. It makes use of the XL.UI.CONSOLE module, locally abbreviated as IO, which provides the writeln procedure. The CONSOLE module is the simplest of the available user interfaces defined in XL2. It features the three traditional text streams called standard output, standard input and standard error (similar to C's stdin, stdout and stderr). There are other user interfaces available for more complex tasks. It is also possible to put the code in a procedure. The procedure can have any name, though Main is often used by convention (as in C). The procedure to execute first is specified at build time. This makes it possible for instance to create a Test procedure in software modules and to use that as the top-level procedure for unit testing.
import IO = XL.UI.CONSOLE procedure Main is IO.WriteLn "Hello World"
|
Copyright 2008 Christophe de Dinechin (Blog)
E-mail: XL Mailing List (polluted by spam, unfortunately)