[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: List functions
From: |
Marco Maggi |
Subject: |
Re: List functions |
Date: |
Thu, 02 Dec 2010 10:57:55 +0100 |
"Hans Aberg" wrote:
> I am writing on a parser that translates normal function
> syntax in to Guile code.
I do not know which scenario you are working with, but it is
perfectly possible to convert the input syntax:
((sin , cos , tan) 1.2)
to the output:
((lambda args
(map (lambda (f)
(apply f args))
(list sin cos tan)))
1.2)
if you accept to write the input syntax expressions only as
part of a macro use, let's call this macro H; so the macro
use:
(h
((sin , cos) 1.2))
can be expanded to:
((lambda args
(map (lambda (f)
(apply f args))
(list sin cos tan)))
1.2)
It is also possible to write the H macro such that any
expression with nested expressions can appear in its use; H
can be made just like the built in syntax BEGIN but with
syntax different from standard Scheme. Example:
(h
(display (+ 4 ((sin , cos) 1.2))))
Once you have H you can write a DEFINE/H syntax which
works just like the standard DEFINE but accepts in its body
the modified syntax:
(define/h (doit x y)
(display (+ x ((sin , cos) y))))
The tool to do it is the syntax-case macro system.
HTH
--
Marco Maggi
- Re: List functions, (continued)
- Re: List functions, Hans Aberg, 2010/12/01
- Re: List functions, Keith Wright, 2010/12/01
- Re: List functions, Hans Aberg, 2010/12/01
- Re: List functions, Hans Aberg, 2010/12/01
- Re: List functions, Keith Wright, 2010/12/01
- Re: List functions, Hans Aberg, 2010/12/01
- Re: List functions, Hans Aberg, 2010/12/01
- Re: List functions, Hans Aberg, 2010/12/03
Re: List functions, Andy Wingo, 2010/12/01
Re: List functions,
Marco Maggi <=