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

Can't use lambda-shape arguments in comparison function #44

Closed
omgitsraven opened this issue Oct 5, 2017 · 2 comments
Closed

Can't use lambda-shape arguments in comparison function #44

omgitsraven opened this issue Oct 5, 2017 · 2 comments

Comments

@omgitsraven
Copy link
Collaborator

I'm extremely new to Scheme, so it's possible this is a silly mistake on my end, but I'm having an issue that works in the general case but not inside of a lambda-shape:

(lambda-shape (x y z) (if (> x 0) x 0) )
gives an error that says

wrong-type-arg: Wrong type: #<<tree> 139e64140>

Stack trace:
0: (lambda-shape (x y z) (if (> x 0) x 0))

even though
(let ((x 1)) (if (> x 0) x 0) )
works fine, so it isn't some kind of syntax thing; it seems like for some operations, the x y z arguments aren't treated like numbers? (even though for functions like + it works fine...)

@mkeeter
Copy link
Member

mkeeter commented Oct 5, 2017

lambda-shape isn't powerful enough to evaluate arbitrary Scheme code; it's intended to JIT a (basically) arithmetic expression. In this case, the issue is that lambda-shape doesn't accept conditionals, since the branches are evaluated lazily rather than eagerly.

There's a little more theory about the JITting here.

In this case, you can use (lambda-shape (x y z) (max x 0)) as an alternative.

In general, the functions that lambda-shape will accept are defined in ao-guile.cpp here.

@mkeeter
Copy link
Member

mkeeter commented Feb 24, 2018

This came up again recently, and now both gives a better error message and is documented here, so I'm going to close this issue.

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