define-macro vs define-syntax 
Author Message
 define-macro vs define-syntax

Anyone help me.
In guile,
I can not change the following code using defmacro
into the code using define-syntax.

define-macro codes:
(define (stringify thing)
   ((string? thing) thing)
   ((symbol? thing)
    (symbol->string thing))
   ((number? thing)
    (number->string thing))
    (error "can only stringify strings, symbols, numbers" thing))))

(define-macro (exe . arg)

(define-macro (bg . arg)
  `(let ((pid (primitive-fork)))
     (sigaction SIGCHLD SIG_IGN)
     (case pid


(define-macro (fg . arg)

(define-macro (bg-scm . arg)
  `(let ((pid (primitive-fork)))
     (sigaction SIGCHLD SIG_IGN)
     (case pid
       ((0) ,arg (primitive-exit))
       (else pid))))

(define-macro (mbg-scm . arg)

(define-macro (mfg . arguments)

(define-macro (mbg . arguments)

(define-macro (cmd . args)

                      ((eq? '& (car x))
                       (cons mbg (cdr x)))
                      ((eq? 'scm (car x))
                       (cons begin (cdr x)))
                      ((eq? 'scm& (car x))
                       (cons mbg-scm (cdr x)))
                       (cons fg x)))) args)))

that is, (cmd (& (ls) (ps)) (ls -a) (ps -as)) is possible.
But in define-syntax, I cannot use the above expression.
And only possible in following form (cmd-syntax (& (ls) (ps)) (% (ls -a) (ps)))
(define-syntax cmd-syntax
  (syntax-rules (% & scm scm&)
    ((cmd-syntax (% a ...) b1 b2 ...)
     (begin (mfg a ...)
            (cmd-syntax b1 b2 ...)))
    ((cmd-syntax (& a ...) b1 b2 ...)
     (begin (mbg a ...)
            (cmd-syntax b1 b2 ...)))
    ((cmd-syntax (scm& a ...) b1 b2 ...)
     (begin (mbg-scm a ...)
            (cmd-syntax b1 b2 ...)))
    ((cmd-syntax (scm a ...) b1 b2 ...)
     (begin (begin a ...)
            (cmd-syntax b1 b2 ...)))
    ((cmd-syntax (% a ...))
     (mfg a ...))
    ((cmd-syntax (& a ...))
     (mbg a ...))
    ((cmd-syntax (scm& a ...))
     (mbg-scm a ...))
    ((cmd-syntax (scm a ...))
     (begin a ...))))

Joo churlsoo

Thu, 03 Oct 2002 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Macros defining macros with define-syntax

2. define-macro -> define-syntax

3. is define-syntax inside define-syntax OK?

4. Scheme macro source: define/keyed, for defining keyword-triggered arguments

5. shadows of define and define-syntax

6. define in define-syntax

7. defmacro/define-macro using syntax-case

8. Question about a macro-defining macro

9. Macro-Defining Macros

10. help sought for macro defining macro

11. Load-time problem with a macro that defines a macro

12. define-syntax must be followed by syntax-rules ??


Powered by phpBB® Forum Software