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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:35:29+00:00 2026-05-31T05:35:29+00:00

I started learning Common Lisp recently, and (just for fun) decided to rename the

  • 0

I started learning Common Lisp recently, and (just for fun) decided to rename the lambda macro.

My attempt was this:

> (defmacro λ (args &body body) `(lambda ,args ,@body))

It seems to expand correctly when by itself:

> (macroexpand-1 '(λ (x) (* x x)))
(LAMBDA (X) (* X X))

But when it’s nested inside an expression, execution fails:

> ((λ (x) (* x x)) 2)
(Λ (X) (* X X)) is not a function name; try using a symbol instead

I am probably missing something obvious about macro expansion, but couldn’t find out what it is.

Maybe you can help me out?

edit:
It does work with lambda:

> ((lambda (x) (* x x)) 2)
4

edit 2:
One way to make it work (as suggested by Rainer):

> (set-macro-character #\λ (lambda (stream char) (quote lambda)))

(tested in Clozure CL)

  • 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-31T05:35:30+00:00Added an answer on May 31, 2026 at 5:35 am

    In Common Lisp LAMBDA is two different things: a macro and a symbol which can be used in a LAMBDA expression.

    The LAMBDA expression:

    (function (lambda (x) (foo x)))
    

    shorter written as

    #'(lambda (x) (foo x))
    

    An applied lambda expression is also valid:

    ((lambda (x) (+ x x)) 4)
    

    Above both forms are part of the core syntax of Common Lisp.

    Late in the definition of Common Lisp a macro called LAMBDA has been added. Confusingly enough, but with good intentions. 😉 It is documented as Macro LAMBDA.

    (lambda (x) (+ x x))
    

    expands into

    (function (lambda (x) (+ x x))
    

    It makes Common Lisp code look slightly more like Scheme code and then it is not necessary to write

    (mapcar #'(lambda (x) (+ x x)) some-list)
    

    With the LAMBDA macro we can write

    (mapcar (lambda (x) (+ x x)) some-list)
    

    Your example fails because

    ((my-lambda (x) (* x x)) 2)
    

    is not valid Common Lisp syntax.

    Common Lisp expects either

    • a data object
    • a variable
    • a function call in the form (function args...)
    • a function call in the form ((lambda (arglist ...) body) args...)
    • a macro form like (macro-name forms...)
    • a special form using one of the built-in special operators like FUNCTION, LET, …
      defined in the list of special operators in Common Lisp

    As you can see a syntax of

    ((macro-name forms...) forms...)
    

    is not a part of Common Lisp.

    It is possible to read the character λ as LAMBDA:

    (defun λ-reader (stream char)
      (declare (ignore char stream))
      'LAMBDA)
    
    (set-macro-character #\λ #'λ-reader)
    

    Example:

    CL-USER 1 > ((λ (x) (* x x)) 3)
    9
    
    CL-USER 2 > '(λ (x) (* x x))
    (LAMBDA (X) (* X X))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started learning Common Lisp a few days ago, and I'm trying to
I've just started learning Common Lisp--and rapidly falling in love with it--and I've just
I've just started learning Lisp and I can't figure out how to compile and
I've just started learning linq and lambda expressions, and they seem to be a
I have recently started learning F#, and this is the first time I've ever
Just started learning PySide and is having problem with QTimer I have this #!/usr/bin/python
When I started learning CL from Practical Common Lisp, as is preached in the
Just started learning Haskell. I have an empty source file with this inside: pe
Started learning javascript yesterday at CodeAcademy and decided I could actually write code. Just
I recently started learning Emacs . I went through the tutorial, read some introductory

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.