Manual - Expressions Up
 Contents   News   View 

Syntax Previous Next

Syntax

Users communicate with Quantum via the Quantum language which has a syntax.  Quantum "sentences" are read in as trees whose "words" are atoms and whose "phrases" are Expr's, Array's or Struct's.   The "words" and "phrases" are the leaves and non-leaves of Quantum trees.  Although not every Quantum object can be considered a tree, every Quantum object which can be Read or Printed, is a tree.  Learning the following syntax is essential to the successful use of Quantum.  If you don't "grok" all of it right away, don't worry.  The rest of the Learning Manual will help you "grok" through sufficient examples.  "Grok" as much as you can and move on.

Comment's.  Begin with // and continue to the end of line.  // This is a comment. , etc. Comments are thrown away by Read as though they were white space.
Integer's.  Optionally signed strings of digits.  -2, -1, 0, 1, 2, ...  123456789, etc.
Float's.  Optionally signed strings of digits containing a decimal point with an optional exponent.  -2.5, -1.234, 0.0, 3.14159, 123456789., 3.141592654e+40 , etc. Floats described in Kernighan and Ritchie's book "The C Programming Language" are acceptable to Quantum.
Ratio's.  Optionally signed strings of digits containing a slash.  3/4, -1000/999, 15/2, 13/1000, etc.
Complex's_I is a Complex , and so are the Quantum objects returned by evaluating either (Complex x y) or (+ x (* y _I)) where x and y are Real numbers.
Infinity's_Infinity is an Infinity , and so are the Quantum objects returned by Evaluating either (Infinity x) or (* x _Infinity).
Symbol's.  Strings of characters that:
(1) Do not begin with ', ", `, ,, #, (, ), [, ], or //.
(2) Do not contain (, ), [, ], or //.
(3) Do not parse as Number's.   In particular, do not parse as _I or _Infinity, which are Number's.
(4) Or, alternatively to (1), (2), and (3), begin and end with | characters.  This syntax is used for Symbol's with funny PrintPrint names which you will rarely see or want to use.
String's.  Strings of characters delimited by " characters.  "life on Mars", "volcanoes on Io" , etc. Strings described in Kernighan and Ritchie's book "The C Programming Language" are acceptable to Quantum.
Char's.  A character surrounded by #' and '#'A', #'B', #'C', etc. Characters described in Kernighan and Ritchie's book "The C Programming Language", preceded by #, are acceptable to Quantum.
Expr's.  Sequences of Quantum objects surrounded by parentheses ( and )(f_1 f_2 ...  f_n), etc.
Array's.  Sequences of Quantum objects surrounded by brackets [ and ], e.g. [f_1 f_2 ...  f_n], are
1-dimensional Array's.  Nested brackets preceded by a sharp sign #, e.g. #[[1 2][3 4]], are
n-dimensional Array's (n≥2).
Struct's.  Quantum Expr's preceded by a sharp #.  Quantum Struct's are created via use of Quantum's DefStruct functionality.  #(a b c), etc.
Other's.  Quantum Other objects, like Button's, Color's, Font's, Stream's, and Window's, can be Printed, but they cannot be Read back in.  Window#8709488, Pen#8709792, etc.



©2004-2024 Planet Quantum Kelly Roach