This specification is not very complete, but still documents Adscript.
Adscript Data Notation is a modified version of EDN. It may become its own spec in the future, but at the moment it is embedded here.
adn type | implementation | example |
---|---|---|
id |
none (resolved at compile time) | f |
char |
unsigned int |
\A |
int |
int64_t |
42 |
float |
double |
13.37 |
str |
char* |
"hi" |
list |
none (resolved at compile time) | (f 1) |
hetvec |
void** |
["hi" 2] |
homovec |
T* |
#[1 2] |
Maps are to be defined. (Probably {1 2}
)
In Adscript there is another native data type: The function. All functions that are not natively implemented are "first-class values".
Functions can be created using the fn
function and called using a list
:
(fn [<parameters>] <return type> <body>)
;; arguments of variable length
(fn [<parameters>]' <return type> <body>)
For example:
((fn [int i] int i) 1)
By quoting a list you can create a struct data type.
'(int a int b int c)
Defines a compile-time constant.
(def <identifier> <value>)
Defines a data type.
(deft <identifier> <data type>)
(deft int32 i32)
(deft xy '(int32 x int32 y))
Defines non-anonymous functions.
(defn <identifier> [<parameters>] <return type> <body>)
Defines a "final variable"/"run time constant", works like let
in Clojure.
(let <identifier> <value>)
(let a 42)
Defines a variable that can be changed later.
(var <identifier> <value>)
(var a 42)
Sets the value for a variable or array element.
It can also be used for setting a pointer's value, please use setptr
instead.
(set <id> <value>)
(set <element> <value>)
(set a 42)
(var b #[1 2 4 8 1])
(set (b 4) 16)
Sets the value for a pointer.
(setptr <pointer> <value>)
(var i 21)
(setptr (ref i) 42)
(fn [] )
These functions are so obvious that they will be documented later.
A conditional expression, exactly like in Clojure.
(if <condition> <then> <else>)
(if 1 42 10)
Creates a pointer to a reference.
(ref <value>)
(ref (#[1 2 3] 1))
Dereferences a pointer.
(deref <pointer>)
(deref (ref ("ABC*" 3)))
Equivalent to the asm "function" in c with llvm IR.
Equivalent to the asm "function" in c but with c code.
Equivalent to the asm "function" in c but with c++ code.