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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:40:38+00:00 2026-05-13T11:40:38+00:00

I want to make a helper macro for writing match-extensions. I have something like

  • 0

I want to make a helper macro for writing match-extensions. I have something like this:

(define-match-expander my-expander
  (λ (stx)
    (let* ([dat (cdr (syntax-e stx))]
           [var1 (car dat))]
           [var2 (cadr dat)])
      ;transformer goes here )))

So I wanted a macro that will do this let binding. I’ve started with something like this:

(define-syntax-rule (define-my-expander (id vars ...) body)
  (define-match-expander id
    (λ (stx)
      (match-let ([(vars ...) (cdr (syntax-e stx))])
        body))))

but match-let isn’t defined in transformation time.

First question would be is there any other way of doing this (making this expanders, I mean)? Maybe there is already something similar in plt-scheme that I’m not aware of, or I’m doing it wrong in some way.

Regardless of answer on the first question, if I ever want to bound list of variables to list of values inside of a macro, how should I do it?

EDIT: In combination with Eli’s answer macro now looks like this:

(define-syntax-rule (define-my-expander (id vars ...) body)
  (define-match-expander id
    (λ (stx)
      (syntax-case stx ()
        [(_ vars ...)
         body]))))
  • 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-13T11:40:39+00:00Added an answer on May 13, 2026 at 11:40 am

    I don’t know what it is that you’re trying to achieve, but my guess is that this goes in the right direction:

    (define-match-expander my-expander
      (lambda (stx)
        (syntax-case stx ()
          [(_ (var1 var2) stuff ...)
           ;; use #'var1 #'var2 and #'(stuff ...) here
           ])))
    

    The thing is that syntax-e is used to “unwrap” a syntax object and give you what it holds — but the actual content may surprise you. For example, (foo . (bar)) will have a little different contents than (foo bar). So generally speaking, using syntax-case to do the pattern matching for you is much easier. In addition to being easier, it will also give some sensible error messages when there are errors, instead of what you’d get with your code.

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

Sidebar

Related Questions

I want to make a helper like the following. def my_div some_options, &block #
I have some PowerShell helper functions in a file. I'd like to make them
Let's say I want make some of my sources publicly available via my blog
I have style sheet with a class name changebackgroundcolor i want make change in
I have link for example domain.com/de/controler/action?param=value and I want make actionlink to keep same
I have uploaded a app in production mode to linode. I want make changes
Is there a helper of some sort? I want to make a javascript file,
I want to make a view helper for my whole website. Which fetches entity_names
I want to make my own enhanced spin-off of one of the jQuery helper
I have an object named Charity and I want to make sure that each

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.