Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8445385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:38:44+00:00 2026-06-10T09:38:44+00:00

In Common Lisp (SBCL 1.0.58) why does the macro OR use a gensym, but

  • 0

In Common Lisp (SBCL 1.0.58) why does the macro OR use a gensym, but not AND?

For example,

    CL-USER> (macroexpand '(and 1 2 3 4 5))
    (IF 1
        (AND 2 3 4 5)
        NIL)
    T
    CL-USER> (macroexpand '(or 1 2 3 4 5))
    (LET ((#:G967 1))
      (IF #:G967
          #:G967
          (OR 2 3 4 5)))
    T
    CL-USER> 

I looked at defboot.lisp where the macros are defined but found nothing relevant in the comments.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:38:45+00:00Added an answer on June 10, 2026 at 9:38 am

    That’s because the implemented logic operators are intended to be short-circuiting and to return the value produced by the last form they evaluated.

    To achieve this, and does not need a gensym because the last form it evaluates will either produce NIL or be the result of the final tail call to itself.

    On the other hand, or has to return the first non-NIL value it evaluates, so it cannot rely on the tail call. It needs a gensym to do that, because without one:

    (IF 1
        1
        (OR 2 3 4 5))
    

    1 appears twice in the expansion, and in our case that means the expression that produces 1 is evaluated twice. And you never want that in your macros.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does clojure have a powerful 'loop' like common lisp. for example: get two elements
The following Common Lisp code does not produce the output I would expect it
I have the following Common Lisp function: (defun get-positions (marker) (let ((result nil)) (dotimes
When writing Common Lisp code, I use SLIME. In particular, I compile the buffer
I installed ltk to Steel Bank Common Lisp with asdf-install, but I can't even
I'm trying to learn common lisp currently and I've been using sbcl (I hope
Suppose we use SBCL's #'save-lisp-and-die to create an server applicatioon App1, which works very
Common Lisp HyperSpec says that require and ****modules**** are deprecated. But I still see
In Common Lisp you use the (null x) function to check for empty lists
In Common Lisp package definition, what is the difference between (defpackage #:foo (:use :cl)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.