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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:57:06+00:00 2026-05-31T08:57:06+00:00

For a functional programming assignment, I am writing a scheme macro that translates scheme

  • 0

For a functional programming assignment, I am writing a scheme macro that translates scheme code to coffeescript code. I am using guile on Linux Mint 12, and have (use-syntax (ice-9 syncase)) active.

Currently, I am trying to nest let-syntax in define-syntax and I keep getting an unexpected ‘invalid syntax’ error. Please excuse any poor programming habits as I am a scheme newbie. 🙂

My code:

(define-syntax coffee
  (syntax-rules (define lambda)
    ; translate define function
    ((_ (define arg1 arg2)) 
     (begin
       (let-syntax ((temp
                     (syntax-rules ()
                       ((_) (quote-replace-list 'arg1 'arg2))))))
       (if (list? 'arg1) 
           (string-append (coffee (car 'arg1)) " = " 
                          (comma-splice (cdr 'arg1)) " -> " 
                          (coffee temp))
           (string-append (coffee 'arg1) " = " 
                          (coffee arg2)))))))

and my output:

guile> (load "hw2-retry.scm")
guile> (coffee (define (x y) (+ x y)))
ERROR: invalid syntax (let-syntax ((temp (syntax-rules () ((_)
(quote-replace-list (quote #) (quote #)))))))
ABORT: (misc-error)

After several of trying to research this error, I’m starting to think I am just not understanding something fundamental. I was sure you could nest a let-syntax inside a define-syntax. What am I doing wrong?

  • 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-31T08:57:08+00:00Added an answer on May 31, 2026 at 8:57 am

    From the Scheme R5RS specification, let-syntax has the following syntax:

     (let-syntax <bindings> <body>) 
    

    Syntax: should have the form

    ((<keyword> <transformer spec>) ...)
    

    The problem with let-syntax in your code (or at least, one of the problems) is that the if should be enclosed in the body portion, as dyoo mentioned. In other words, you should indent the if, remove a closing parenthesis from the end of line 8, and add that closing paren at the end of line 14.

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

Sidebar

Related Questions

I'm currently completing an assignment that involves using multithreading and multiprocess programming for the
I'm new to functional programming. I have a basic question. I'm using the Hugs
I am using Tkinter in a programming assignment and have the following problem. I
In functional programming, it's often important to optimize any looping code to be tail
Several questions about functional programming languages have got me thinking about whether XSLT is
I'm learning functional programming, and have tried to solve a couple problems in a
I'm reading about functional programming and I've noticed that Pattern Matching is mentioned in
I have been doing some functional programming and had a question. Perhaps I might
As an assignment in operating systems we have to write our own code for
In my programming class we currently have a project that requires us to take

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.