Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling and evaluating variable assignment #14

Closed
emilywoods opened this issue May 16, 2017 · 2 comments
Closed

Compiling and evaluating variable assignment #14

emilywoods opened this issue May 16, 2017 · 2 comments

Comments

@emilywoods
Copy link
Owner

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
Copy link
Collaborator

lpil commented May 16, 2017

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
Copy link
Owner Author

Noted. :) 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants