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 953151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:00:18+00:00 2026-05-16T00:00:18+00:00

I would like to know why most Common Lisp code I see has things

  • 0

I would like to know why most Common Lisp code I see has things like

(mapcar #'(lambda (x) (* x x)) '(1 2 3))

instead of just

(mapcar (lambda (x) (* x x)) '(1 2 3)),

which seems to work as well. I am beginning to learn Common Lisp, and having some background in Scheme, this intrigues me.

Edit: I know that you need #’ with function names because they live in a different namespace than variables. My question is just about #’ before lambda, as lambda already returns a function object (I think). The fact that #’-less lambdas work because of a macro expansion just makes it more intriguing…

  • 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-05-16T00:00:19+00:00Added an answer on May 16, 2026 at 12:00 am

    #'foo is an abbreviation for (function foo) by the reader.

    In CL, there are several different namespaces, #'foo or (function foo) will return the functional value of foo.

    You may want to search for “Lisp-1 vs. Lisp-2”, check other Stackoverflow questions, or read an old article by Pitman and Gabriel in order to learn more about the concept of multiple namespaces (also called slots or cells of symbols).

    The reason that, in the case of lambda, the #' may be omitted in CL is that it is a macro, which expands thusly (taken from the Hyperspec):

    (lambda lambda-list [[declaration* | documentation]] form*)
    ==  (function (lambda lambda-list [[declaration* | documentation]] form*))
    ==  #'(lambda lambda-list [[declaration* | documentation]] form*)
    

    #' may still be used for historic reasons (I think that in Maclisp lambdas didn’t expand to the function form), or because some people think, that tagging lambdas with sharpquotes may make the code more readable or coherent. There may be some special cases in which this makes a difference, but in general, it doesn’t really matter which form you choose.

    I guess you can think of it like this: (function (lambda ...)) returns the function (lambda ...) creates. Note that lambda in the CL Hyperspec has both a macro AND a symbol entry. From the latter:

    A lambda expression is a list that can
    be used in place of a function name in
    certain contexts to denote a function
    by directly describing its behavior
    rather than indirectly by referring to
    the name of an established function.

    From the documentation of function:

    If name is a lambda expression, then a
    lexical closure is returned.

    I think the difference is also related to calling lambda forms like this: ((lambda ...) ...) where it is treated as a form to be evaluated, vs. (funcall #'(lambda ...) ...). If you want to read more on the topic, there is a c.l.l thread about it.

    Some quotes from that thread:

    (lambda (x) ... by itself is just some
    unquoted list structure. It is its
    appearance as an argument to the
    FUNCTION special form (function
    (lambda (x) ...
    that causes the
    function object to exist

    and:

    It’s also compounded by the fact that
    the LAMBDA macro was a rather late
    addition the ANSI Common Lisp, so all
    of the really old guys (i.e., like me)
    learned their lisp when you needed to
    supply the #’ to the lambda expression
    in the mapping functions. Otherwise
    the non-existent lambda function would
    be invoked.

    The macro addition changed that, but
    some of us are too set in our ways to
    want to change.

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

Sidebar

Ask A Question

Stats

  • Questions 467k
  • Answers 467k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You should make each of your Beanstalk client a git… May 16, 2026 at 2:11 am
  • Editorial Team
    Editorial Team added an answer The answer as George suggested it depends...but you may have… May 16, 2026 at 2:11 am
  • Editorial Team
    Editorial Team added an answer Before showing the pop-up, ask the server how long ago… May 16, 2026 at 2:11 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.