We should be able to create a minimalistic type system for lifp.
Something like:
;; [number number] -> number
(def! sum (fn (a b) (+ a b)))
Rules:
;; starts a type block
-> indicates return value
- scalar types are
bool number builtin nil special string any
- functions should be typed by their type signature (i.e., no
closure but (number) -> number)
- lists are typed with
() and their type (number) is a list of numbers
... means variadic arguments (NOT SUPPORTED BY RUNTIME YET)
- variadic arguments are always last (NOT SUPPORTED BY RUNTIME YET)
More examples
;; number
(def! a 12)
;; [number] -> bool
(def! pos? (fn (a) (> a 0)))
;; [(number) number] -> number
(def! nth (fn (list num) (list:nth list num)))
We should be able to create a minimalistic type system for lifp.
Something like:
Rules:
;;starts a type block->indicates return valueboolnumberbuiltinnilspecialstringanyclosurebut(number) -> number)()and their type(number)is a list of numbers...means variadic arguments (NOT SUPPORTED BY RUNTIME YET)More examples