|
|
 |
 |
 |
 |
Scheme Programming Language
|
 |
 |
 |
 |
 |
 |
 |
 |
how do I rewrite this simple macro so that r5rs compiler will compile.
hi how do I rewrite this simple macro so that r5rs compiler will compile. I've met several compilers or interpreters that claim r5rs choke on this simple macro. There must be some miscommnunication. (define-syntax myor (syntax-rules () ((myor) #f) ((myor e) e) ((myor e1 . es) (let ((r e1)) (if r r (myor . es)))))) Attempt to evaluate illegal object: () I don't know what it is expecting. I am looking at examples from other sources that looks like these: (define-syntax or2 (lambda (x) (syntax-case x () ((_ e1 e2) (syntax ((lambda (t) (if t t e2)) e1)))))) Can someone tell me what version of define-syntax this is written for? This is becoming really funny that the function that is defining syntax should cause this much trouble....
"maina @gmail.com" <maina @gmail.com> writes: > how do I rewrite this simple macro so that r5rs compiler will compile. > I've met several compilers or interpreters that claim r5rs choke on > this simple macro. There must be some miscommnunication. > (define-syntax myor > (syntax-rules () > ((myor) #f) > ((myor e) e) > ((myor e1 . es) > (let ((r e1)) (if r r (myor . es)))))) > Attempt to evaluate illegal object: () > I don't know what it is expecting.
Why not just use the ... notation. (syntax-rules () ((myor) #f) ((myor e) e) ((myor e1 e2 ...) (let ((r e1)) (if r r (myor e2 ...))))) > Can someone tell me what version of define-syntax this is written > for?
Who cares? Why use a notation that isn't generally accepted? -- Barry Fishman
On Mar 29, 8:16 pm, "maina@gmail.com" <maina@gmail.com> wrote: > hi > how do I rewrite this simple macro so that r5rs compiler will compile. > I've met several compilers or interpreters that claim r5rs choke on > this simple macro. There must be some miscommnunication. > (define-syntax myor > (syntax-rules () > ((myor) #f) > ((myor e) e) > ((myor e1 . es) > (let ((r e1)) (if r r (myor . es)))))) > Attempt to evaluate illegal object: ()
What implementation are you using? > I don't know what it is expecting. > I am looking at examples from other sources that looks like these: > (define-syntax or2 > (lambda (x) > (syntax-case x () > ((_ e1 e2) > (syntax ((lambda (t) (if t t e2)) e1)))))) > Can someone tell me what version of define-syntax this is written for?
This is for syntax-case systems. It should work under Petite/Chez Scheme, Dr/MzScheme, Chicken, SISC, among others perhaps. In some implementations (like Chicken), you have to do something special to load it since it's not installed by default. In Chez or MzScheme, it is available by default (just type it in the repl and it should work). Aziz,,,
On Mar 30, 9:25 am, "Abdulaziz Ghuloum" <aghul@gmail.com> wrote:
> On Mar 29, 8:16 pm, "maina @gmail.com" <maina @gmail.com> wrote: > > hi > > how do I rewrite this simple macro so that r5rs compiler will compile. > > I've met several compilers or interpreters that claim r5rs choke on > > this simple macro. There must be some miscommnunication. > > (define-syntax myor > > (syntax-rules () > > ((myor) #f) > > ((myor e) e) > > ((myor e1 . es) > > (let ((r e1)) (if r r (myor . es)))))) > > Attempt to evaluate illegal object: () > What implementation are you using?
I have about 20 different implementations installed.
> > I don't know what it is expecting. > > I am looking at examples from other sources that looks like these: > > (define-syntax or2 > > (lambda (x) > > (syntax-case x () > > ((_ e1 e2) > > (syntax ((lambda (t) (if t t e2)) e1)))))) > > Can someone tell me what version of define-syntax this is written for? > This is for syntax-case systems. It should work under Petite/Chez > Scheme, Dr/MzScheme, Chicken, SISC, among others perhaps. In some > implementations (like Chicken), you have to do something special to > load it since it's not installed by default. In Chez or MzScheme, it > is available by default (just type it in the repl and it should work). > Aziz,,,
maina @gmail.com wrote: > how do I rewrite this simple macro so that r5rs compiler will compile. > I've met several compilers or interpreters that claim r5rs choke on > this simple macro. There must be some miscommnunication. Some systems that claim to be R5RS-compliant aren't. Others may be R5RS-compliant if you use a particular set of command-line or runtime switches, but are not R5RS-compliant in their default configurations. Will
|
 |
 |
 |
 |
|