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

Re: helper macro construct-from-string for srfi-108

On 03/20/2013 11:34 PM, Per Bothner wrote:
The idea is that you could implement $construct$:cname thus:

(define-syntax $construct$:cname
   (syntax-rules ()
     ((_ . args) (construct-from-string cname-maker . args))))

This assumes you also a function cname-maker.

&cname{abc&(+ 3 4)z} ==> (cname-maker "abc7z")
&cname[id: "n7"]{&(+ 3 4)abc} ==> (cname-maker id: "n7" "7abc")

I came up with something that I think is better than
construct-from-string:  A new syntax:

(define-simple-constructor cname cname-maker [str-maker])

This binds $construct$:cname such that:

($construct$:cname [init-arg ... $>>$] text-arg ...)

is mapped to:

(cname-maker init-arg ... (str-maker text-arg ...))

cname-maker and str-maker are user-supplied macros or functions.
I.e. either names of syntax or expression that evaluate to functions.
str-maker defaults to $string$

	--Per Bothner
per@xxxxxxxxxxx   http://per.bothner.com/