kleopatra999 / owl-lisp

Automatically exported from code.google.com/p/owl-lisp
2 stars 1 forks source link

no syntax-error signaling in macros #117

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
(define-syntax simple-let
  (syntax-rules ()
    ((_ (head ... ((x . y) val) . tail) body1 body2 ...)
        (syntax-error "expected an identifier but got" (x . y)))
    ((_ ((name val) ...) body1 body2 ...) ((lambda (name ...) body1 body2 ...)
val ...))))

Original issue reported on code.google.com by aohelin on 7 Jan 2012 at 7:51

GoogleCodeExporter commented 9 years ago
Added by mapping syntax-error to a normal error. Will have to check the spec if 
this causes some difference, but will treat that as a separate issue later.

$ cat > /tmp/fail.l
(define-syntax simple-let
  (syntax-rules ()
      ((_ (head ... ((x . y) val) . tail) body1 body2 ...) 
         (syntax-error "expected an identifier but got" (x . y)))
      ((_ ((name val) ...) body1 body2 ...)
         ((lambda (name ...) body1 body2 ...) val ...))))

(simple-let
   ((foo 42)
    ((+ 1 2) 43))
   (+ foo 1))

(define canary "dead")

$ cd owl-lisp/
$ bin/vm fasl/ol.fasl
You see a prompt
> (define canary "live")
canary
> ,load "/tmp/fail.l"
Could not load /tmp/fail.l because 
  Syntax error:  
    expected an identifier but got 
      + 1 2 
> canary
live
> 

Original comment by aohelin on 8 Jan 2012 at 5:09