Compiling and evaluating variable assignment
emilywoods opened this issue · 2 comments
emilywoods commented
Local variables
Input lisp:
(let [x (+ 1 2) ] )
compiles to:
x = 1 + 2
which evaluates to:
3
Global variables
Input lisp:
(def input "Hello")
compiles to:
$input = "Hello"
which evaluates to:
"Hello"
lpil commented
For the let you may want to think a bit about limiting the scope of the variable.
(let [x 1]
x + x)
x
This should error at the end as x
is undefined, however it would not error if we compiled it to this ruby:
x = 1
x + x
x
Instead we might want something like this
begin
x = 1
x + x
end
x
emilywoods commented
Noted. :) 👍