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

  • Home
  • SEARCH
  • 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 67185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:13:13+00:00 2026-05-10T19:13:13+00:00

Many examples of macros seem to be about hiding lambdas, e.g. with-open-file in CL.

  • 0

Many examples of macros seem to be about hiding lambdas, e.g. with-open-file in CL. I’m looking for some more exotic uses of macros, particularly in PLT Scheme. I’d like to get a feel for when to consider using a macro vs. using functions.

  • 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. 2026-05-10T19:13:13+00:00Added an answer on May 10, 2026 at 7:13 pm

    I only use Scheme macros (define-syntax) for tiny things like better lambda syntax:

    (define-syntax [: x]   (syntax-case x ()     ([src-: e es ...]      (syntax-case (datum->syntax-object #'src-: '_) ()        (_ #'(lambda (_) (e es ...))))))) 

    Which lets you write

    [: / _ 2]  ; <-- much better than (lambda (x) (/ x 2)) 

    Dan Friedman has a mind-bending implementation of OO using macros: http://www.cs.indiana.edu/~dfried/ooo.pdf

    But honestly, all the useful macros I’ve defined are stolen from Paul Graham’s On Lisp and are generally easier to write with defmacro (define-macro in PLT Scheme). For example, aif is pretty ugly with define-syntax.

    (define-syntax (aif x)   (syntax-case x ()     [(src-aif test then else)      (syntax-case (datum->syntax-object (syntax src-aif) '_) ()        [_ (syntax (let ([_ test]) (if (and _ (not (null? _))) then else)))])])) 

    define-syntax is odd in that it’s only easy to use for very simple macros, where you are glad of the inability to capture variables; and very complicated macro DSLs, where you are glad of the inability to capture variables easily. In the first case you want to write the code without thinking about it, and in the second case you have thought enough about the DSL that you are willing to write part of it in the syntax-rules/syntax-case language which is not Scheme in order to avoid mystifying bugs.


    But I don’t use macros that much in Scheme. Idiomatic Scheme is so functional that many times you just want to write a functional program and then hide a few lambdas. I got on the functional train and now believe that if you have a lazy language or a good syntax for lambda, even that isn’t necessary, so macros are not all that useful in a purely functional style.

    So I’d recommend Practical Common Lisp and On Lisp. If you want to use PLT Scheme, I think most of their defmacro macros will work with define-macro. Or just use Common Lisp.

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

Sidebar

Ask A Question

Stats

  • Questions 62k
  • Answers 62k
  • 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
  • added an answer sigh The solution annoyingly simple... Why couldn't I just have… May 11, 2026 at 10:11 am
  • added an answer The error is occurring because quotes (single and double) are… May 11, 2026 at 10:11 am
  • added an answer %time% should work, provided enough time has elapsed between calls:… May 11, 2026 at 10:11 am

Related Questions

Many examples of macros seem to be about hiding lambdas, e.g. with-open-file in CL.
Unlike many of the ASP.NET documentation and examples, I'm doing a gridview list on
I have this Perl script with many defined constants of configuration files. For example:
I have seen many examples, with many 'no, you missed something' comments. What is
Earlier I asked a question about why I see so many examples use the
I need to upload images using FileUpload without postback(using Ajax).I tried many examples.But in
It seems like many OO discussions use Java or C# as examples (e.g. Head
Many C++ books contain example code like this... std::cout << Test line << std::endl;
I have seen simple example Ajax source codes in many online tutorials. What I
There are many phones, each with it's own icon size (for example, Nokia has

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.