Hacker News

Lisp in the Rust Type System

Lisp in the Rust Type System

Comments

Lisp in Rust trait system.

  • Each symbol must be manually declared via defkey!() macro
  • Numbers cannot be negative
  • Numbers are only in range of 0..8192; you can modify build.rs to generate more natural numbers, but then you have to run with RUST_MIN_STACK increased
  • No (defmacro ...)
  • No eval
  • I have not tested it extensively
  • Recursive functions
  • Global and lexical environments (via let bindings)
  • Function calls apply properly working call/ec
type DefFac = expr!(defun SymFac (SymN) (if (= SymN 0) 1 (* SymN (SymFac (- SymN 1)))));
type Global2 = <DefFac as Eval>::GlobalOut;
type Fac5 = EvalValue<Global2>;
assert_same::<Fac5, N120>();
println!("(fac 5) => {:?}", <Fac5 as ToRuntime>::to_rt());

call/ec demo (escape continuation, explicit tag)

(call/ec cc (lambda (k) (+ 1 (k 5)))) => 5

defkey!(SymCC, N10);
defkey!(SymK, N11);
type CallECExpr = expr!((call/ec SymCC (lambda (SymK) (+ 1 (SymK 5)))));
type CallECResult = EvalValue<CallECExpr>;
assert_same::<CallECResult, N5>();
println!(
    "(call/ec cc (lambda (k) (+ 1 (k 5)))) => {:?}",
    <CallECResult as ToRuntime>::to_rt()
);

Comments

No comments yet. Start the discussion.