|
|
|
Note: The language quick summary is intended for people who already know QDL and just need a syntax reminder once in awhile. It consists of a simplified syntax spec and several examples. This may also be helpful for expert programmers looking for a birds-eye-view of QDL syntax.
VariableList : DataType Initializer(s);
X: Integer; // An integer named X, not initialized
Y, Z: String ("Hello"); // Strings containing "Hello" named Y and Z.
AnArray: [10] Integer; // An array of ten integers (0 through 9)
AnArray: [-5..5] Integer { 1, 2, 3, 4, 5, ... };
// An array of 11 integers (-5 through 5); elements -5 through -1 are
// initialized with 1 through 5, and the rest are not initialized.
Function Name (Arguments)
[: ReturnType] Do
[Statement(s)]
End [Function];
Function PrintHello Do
// Prints "Hello"
StdOut.Print "Hello!\n";
End;
Function Square (X: Double): Double Do
// Calculates the square (X times itself)
Return X * X;
End;
Function nPr ("[Of]" N: Integer "Pick" R: Integer)
Result: Integer(N) Do
// Probability function: If you have T items total, how many
// combinations of R items are there? For example, if you have
// 5 different balls and pick 3, the number of combinations is
// nPr (Of 5 Pick 3), which equals 5*4*3=60.
X: Integer;
For X = N - 1; X > N - R; X++ Do
Result *= X;
End;
Function Main Do
PrintHello; // Calling a function with no arguments
Square 3; // Calling a function and ignoring the return value
StdOut.Print Square(5), "\n"; // Calling a function (Square), and
// using the return value as input to another function
// (StdOut.Print)
StdOut.Print nPr (5 Pick 3) // Calculate and print the number of
// combinations of 3 out of 5 different items.
End;
/* Output:
Hello!
25
60
*/
Enum Name [Inherits IntegerTypeName] { Members };
Enum Binary { Zero, One };
// Zero=0, One=1
Enum Fruits Inherits Int16 {
// "Inherits Int16" means Fruits are 16-bit signed numbers
Apple, Grape, Orange = 6, Tangerine
}; // Apple=0, Grape=1, Orange=6, Tangerine=7
[Modifiers] Class ClassName :
[Clauses]
[Functions/Variables/AccessModes/InnerClasses/Enums]
End Class;
Clauses:
Access Modes: these affect the accessibility of the members that are listed afterward as follows:
| Table of Contents | Qwertie's Site/Mirror |
|