The type-annotation in (def … (var …)) has 3 use cases:
a: declaring variables uninitialized
b: ensure type of a form
c: type-dependant initializing
These abilities may be useful without declaring vars too.
;;;a:
(fun (type-prototype int)) ;;function needs int, but doesn't use it in this case, or only needs it for dispatch
;;;b:
(g (assert-type T (f x))) ;;(f x) has to be T, but will be passed to function immeditely, similar to `(the T x)` in CL
;;;c:
(make uint16 1) ;;instead of `(cast 1 uint16)`
(make (array-of 2 float) (array 1.0 2.0)) ;;instead of `(array-of 2 float (array 1.0 2.0))`
(make T ((value 1))) ;;instead of (T (value 1))
;;this makes initializing more uniform
all these functionalities can also be expressed as a single function. Let's call it var.
with this every varialbe type declaration like (let ((a T [val])) …) can be written as (let ((a \ (var T [val]))) …).
So the type annotation could be dropped entirely (which is \ mostly in my code anyway).
Maybe this will make the code more clear, becuase types are only derived from the value.
But an "anonymous var" is also useful without dropping the type annotation.
The type-annotation in
(def … (var …))
has 3 use cases: a: declaring variables uninitialized b: ensure type of a form c: type-dependant initializingThese abilities may be useful without declaring vars too.
all these functionalities can also be expressed as a single function. Let's call it
var
. with this every varialbe type declaration like(let ((a T [val])) …)
can be written as(let ((a \ (var T [val]))) …)
.So the type annotation could be dropped entirely (which is \ mostly in my code anyway). Maybe this will make the code more clear, becuase types are only derived from the value. But an "anonymous var" is also useful without dropping the type annotation.