- like Clojure / Elixir
- not fanatic like Haskell
- syntax like JS / Python / Ruby / Elixir
- avoid lisp syntax due to stigma
- avoid Haskell syntax because it sucks
- regular, predictable syntax like lisps - especially Clojure
- no memory management headaches like Rust / C / C++
- start without types, add types to any extent, even dependent types
- typechecking should be done at compile time to whatever extent possible
- the remaining checks should be left for runtime
- enable/disable typechecking for forms/functions
- awesome like Scheme, supporting bignums, complex numbers, ratios, etc.
- fast-enough for general use
- bindings to a fast n-dimensional-vector lib for performance sensitive code
- like Clojure: list, vector, ordered-hash-map, ordered-set
- every top-level public function is a multimethod
- maybe protocols implemented as a special type of multimethods
+(1, 2, 3)
is equivalent to
1.+(2, 3)
If only one arg, the dot and brackets can be elided
1 + 2 + 3
is equivalent to
1.+(2).+(3)
- constant folding
- any form / function whose args are compile-time constants should be evaulated and inlined
let f = fn((m, n), 2 * m + n)
let fm2 = f(2, _)
let fn2 = f(_, 2)
should compile to
let f = fn((m, n), 2 * m + n)
let fm2 = fn((n), 4 + n)
let fn2 = fn((m), 2 * m + 2)
- something between macros and GHC extensions
- can add language features, hopefully in the language itself
- fast
- great recursion capabilities
- native executables
- continuations
- c ffi
- superfast
- runtime optimization, such as dependent type checks
- java ffi
- slow, bloated native executables with some trouble, losing java ffi and with bad gc
ns!(example)
defn!(fact, {}, [n] =>
cond(
n == 0 => 1,
:else => n * fact(n - 1)
)
)
defn!(main!, {:public true}, args =>
do(
println!(fact(5)),
println!(fact("a"))
)
)
- side-effeting forms and functions end with a bang
!
=>
is parsed as,
and is just sugarfact
andmain!
are default methods of multimethods - specialized methods can be added later, even in another ns- the second arg to
defn!
is a map containing metadata - the formal param of
main!
,args
, will contain all the passed args, whereasfact
destructures the param vector to get a single paramn