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

Disallow expressions without parens #31

Open
Samyak2 opened this issue May 11, 2022 · 2 comments
Open

Disallow expressions without parens #31

Samyak2 opened this issue May 11, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@Samyak2
Copy link
Collaborator

Samyak2 commented May 11, 2022

Something like this is heresy against lisp (shows current behaviour):

spresso> print
built-in function
spresso> print "hello"
"hello"
spresso> + 10 20
20
spresso> define x 10
Runtime Error: Symbol not found: x
In input[3]:
1   | define x 10
             ^

spresso>
@Samyak2 Samyak2 added the bug Something isn't working label May 11, 2022
@Samyak2
Copy link
Collaborator Author

Samyak2 commented May 12, 2022

This happens because we allow expressions separated by whitespace (including newlines). Each token in the original example is considered a separate expression which are executed sequentially and the result of the last expression is printed.

Another example which looks normal:

spresso> (define x 10) (define y 20) (define z 30)
30

@Samyak2
Copy link
Collaborator Author

Samyak2 commented May 12, 2022

One option is to only allow multiple expressions separated by newlines and not spaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant