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

Bad OR behaviours #21

Closed
domdefelice opened this issue Mar 7, 2011 · 4 comments
Closed

Bad OR behaviours #21

domdefelice opened this issue Mar 7, 2011 · 4 comments
Labels

Comments

@domdefelice
Copy link

(or FALSE "string") should return "string" but returns 1.
It always returns 0 or 1, but should return 0 (FALSE) or the element that was not FALSE, so to make possible to use something like (print (or variable "default string")).

@jeromebaum
Copy link
Contributor

Another case where we should be following traditional lisp semantics. Just in case: The same goes for IF, AND, COND, etc. so if we have those and they don't already to this, make sure they do (though I believe IF already follows this).

Also, check out this xkcd for some real insight: http://m.xkcd.com/870/.

@Scriptor
Copy link
Owner

The issue here is that PHP doesn't seem to natively support this behavior for its logical operators. I guess the solution would be to convert them to ternary statements but I'm not sure if there'd be a performance penalty. Ideally there shouldn't be, but the PHP internals can be rather messy.

@jeromebaum
Copy link
Contributor

Doesn't the IF implementation just assign a variable? Either way, modulo multiple evaluation (which would be solved with a LET), just translate:

(or a b)

to:

(if a a b)

@Scriptor
Copy link
Owner

Yep, I just wasn't sure if PHP would add some extra overhead to if statements. Some quick benchmarks show that if statements were as fast as ternary statements. I really need to stop irrationally fearing PHP internals :)

Implementing this now.

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

No branches or pull requests

3 participants