XL (programming language): Difference between revisions

Content deleted Content added
No edit summary
Line 61:
 
The XL1 phase contains a large set of plug-ins, notably <code>XLSemantics</code>, that provide common abstractions like [[subroutine]], [[data type]] and [[variable]] [[declaration]] and [[definition]], as well as basic [[structured programming]] statements, like conditionals or loops.
 
XL1 type checking is [[data type|static]], with [[generic programming]] capabilities that are beyond those of languages like C++, including statically-checked variable argument lists. For instance, it is possible to declare that a type is <code>ordered</code> if it has a less-than operator, and to declare a <code>Min</code> function taking any number of arguments using the following code:
 
// A type is ordered if it has a less-than relationship
generic type ordered if
A, B : ordered
Test : boolean := A &lt; B
 
// Generic function for the minimum of one item
function Min(X : ordered) return ordered is
return X
 
// Generic function for the minimum of N item
// The compiler recursively instantiates as needed
function Min(X : ordered; other) return ordered is
result := Min(other)
if X &lt; result then
result := X
 
// Examples of use of the Min just declared
X : real := Min(1.3, 2.56, 7.21)
Y : integer := Min(1, 3, 6, 7, 1, 2)
 
 
== External links ==