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

Consider adding conditionals that test for t #180

Open
kilianmh opened this issue Oct 4, 2024 · 2 comments
Open

Consider adding conditionals that test for t #180

kilianmh opened this issue Oct 4, 2024 · 2 comments

Comments

@kilianmh
Copy link
Contributor

kilianmh commented Oct 4, 2024

Sometime conditionals that test for t instead of non-nil are desired.

In this situation it might be convenient to have:
if-t, when-t, cond-t or maybe even or-t and and-t.

What do you think? @ruricolist

@ruricolist
Copy link
Owner

My first thought is that a function to cast non-t to nil (like partially applied eq t) would accomplish the same thing without needing to introduce macros.

@kilianmh
Copy link
Contributor Author

kilianmh commented Oct 4, 2024

A function should also work and if we inline it there should be no performance penalty.

I can do the PR if you tell me which functions you want and with which name.

It should look like this then?

(defun if-t (test then &optional else)
  "If TEST evaluates to T, evaluate THEN and return its values,
otherwise evaluate ELSE and return its values. ELSE defaults to NIL."
  (if test
      (if (eq test t)
	  then
	  else)
      else))

(declaim (inline if-t))

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