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

check lambda form body structure more strictly #186

Closed
Tracked by #164
porcuquine opened this issue Dec 2, 2022 · 2 comments · Fixed by #253
Closed
Tracked by #164

check lambda form body structure more strictly #186

porcuquine opened this issue Dec 2, 2022 · 2 comments · Fixed by #253
Assignees
Labels
bug Something isn't working circuit Addressing this issue will affect the circuit.
Milestone

Comments

@porcuquine
Copy link
Collaborator

As noted in a comment on #183, we currently allow lambda forms that don't have exactly one body element. It would be better if this led to an error.

Examples:

Lurk REPL welcomes you.
> (lambda (x))
[1 iterations] => <FUNCTION (X) )>
> (lambda (x) 1)
[1 iterations] => <FUNCTION (X) 1)>
> (lambda (x) 1 2)
[1 iterations] => <FUNCTION (X) 1 2)>
> ((lambda (x) 1 2) 9)
[4 iterations] => 1

Since we want to avoid extra destructuring (car_cdr()), which incurs hashing costs in the circuit, the check should not come at the time of creating the function, but later (probably when handling Continuation::Call2 in apply_continuation().), when the body is being inspected.

@porcuquine porcuquine added bug Something isn't working circuit Addressing this issue will affect the circuit. labels Dec 2, 2022
@jpeg07 jpeg07 mentioned this issue Dec 9, 2022
9 tasks
@weissjeffm weissjeffm self-assigned this Dec 15, 2022
@weissjeffm
Copy link
Contributor

@porcuquine I tried implementing it the way you specified, but I find it strange that you are allowed to create a lambda with an invalid body, but you can't call it - was that your intention?

Lurk REPL welcomes you.
> (lambda () 1 2 3)
[1 iterations] => <FUNCTION () 1>
> ((lambda () 1 2 3))
Evaluation error: Function body must be only one element
> 

@porcuquine
Copy link
Collaborator Author

Having completed the cons hashing optimizations, I now suspect we can afford to perform the destructuring earlier — so you can go ahead and change it as you suggest. We'll want to ensure that works without adding a hash to the circuit though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working circuit Addressing this issue will affect the circuit.
Projects
None yet
2 participants