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

Missing return value in functions #1

Open
jcubic opened this issue Sep 26, 2020 · 2 comments
Open

Missing return value in functions #1

jcubic opened this issue Sep 26, 2020 · 2 comments

Comments

@jcubic
Copy link

jcubic commented Sep 26, 2020

I was just playing with your demo page:

(defun bar (x) (* x x))

this map to:

function bar(x) {
x * x;
};

the function don't return anything, in lisp function always return last expression like in Ruby, so it have implicit return.

@jcubic
Copy link
Author

jcubic commented Sep 26, 2020

It seems that you have return-from this is not how lisp works.

@alfonsoromanz
Copy link
Owner

Hey @jcubic, thanks for your input.

You are correct, but I already mentioned that the return value for functions is not supported in this project:

Important: a function in LISP returns the value of the last expression evaluated as the return value, but this is not supported in this simplified LISP version. Instead, to return a value from a function it is required to use the return-from statement explicitly.

I don't remember exactly what was the issue, but at that moment it wasn't easy for me to identify where to put the return value. There was an ambiguity somewhere, especially with recursive functions which can have many return values.

However, this was made just for fun, and I explained in the README the limitations and problems I encountered during the development. If you would like to fix something I'll gladly accept a Pull Request :)

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