chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] [Q] Macro for defining function from string


From: Kristian Lein-Mathisen
Subject: Re: [Chicken-users] [Q] Macro for defining function from string
Date: Fri, 5 Apr 2019 13:03:18 +0300


I'm doing that fort of thing here: https://github.com/kristianlm/chicken-minissh/blob/master/minissh-parsing.scm#L5-L11

Here's another example, perhaps easier to follow:

(import-for-syntax (only (chicken string) conc))
(define-syntax syntax-conc
  (er-macro-transformer
   (lambda (x r t)
     (string->symbol (apply conc (intersperse (cdr x) '-))))))

(expand '(syntax-conc "a" "b" "c")) ;; ==> a-b-c

I would recommend using syntax-rules whenever possible, 
and only using er-macro-transformer when you have to. So, your syntax-rules could
expand to syntax-conc.
K.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]