[Larceny-users] Syntax violations need &syntax

Derick Eddington derick.eddington at gmail.com
Wed Mar 18 19:01:07 EDT 2009


Per R6RS 5.5 "Syntax violations", the below exceptions must have a
condition with type &syntax.  (And probably shouldn't have &error
because of what R6RS says it's for.)

(The below is in ERR5RS mode, but the same issue seems to be happening
in R6RS mode, and I'm guessing ERR5RS mode wants to conform to R6RS in
this matter.)

Larceny v0.97a4 (alpha test) (Mar 18 2009 10:48:46, precise:Linux:unified)
larceny.heap, built on Wed Mar 18 10:50:45 PDT 2009
ERR5RS mode (no libraries have been imported)

> (import
    (rnrs)
    (rnrs eval)
    (xitomatl records))
Autoloading (rnrs)
Autoloading (rnrs eval)
Autoloading (xitomatl records)
Autoloading (rnrs enums)
Autoloading (rnrs lists)
Autoloading (rnrs syntax-case)
Autoloading (rnrs conditions)
Autoloading (err5rs records procedural)
Autoloading (rnrs exceptions)
Autoloading (rnrs hashtables)
Autoloading (rnrs arithmetic bitwise)
Autoloading (rnrs programs)
Autoloading (rnrs files)
Autoloading (rnrs io ports)
Autoloading (larceny deprecated)
Autoloading (rnrs records syntactic)
Autoloading (rnrs records procedural)
Autoloading (rnrs control)
Autoloading (rnrs sorting)
Autoloading (rnrs bytevectors)
Autoloading (rnrs unicode)

> (define-syntax show-ex
    (syntax-rules ()
      ((_ expr)
       (show-ex expr '(rnrs)))
      ((_ expr env ...)
       (guard (ex (else
                   (map (lambda (c)
                          (list c (map (lambda (a) (a c))
                                       (record-type-accessors (record-rtd c)))))
                        (simple-conditions ex))))
         (eval '(let () expr)
               (environment env ...))))))

> (show-ex (lambda ((oops)) 1))

Syntax violation: lambda

Invalid form

Form: (lambda ((oops)) 1)

Trace: 

  (lambda ((oops)) 1)

  (lambda () (lambda ((oops)) 1))

  ((lambda () (lambda ((oops)) 1)))

((#<record &error> ())
 (#<record &who> (syntax-violation))
 (#<record &message> ("lambda: Invalid form"))
 (#<record &irritants> (((lambda ((oops)) 1)))))

> (show-ex (define ((oops)) 1))

Syntax violation: define

Invalid form

Form: (define ((oops)) 1)

Trace: 

  (lambda () (define ((oops)) 1))

  ((lambda () (define ((oops)) 1)))

((#<record &error> ())
 (#<record &who> (syntax-violation))
 (#<record &message> ("define: Invalid form"))
 (#<record &irritants> (((define ((oops)) 1)))))

>


I didn't check other forms, and I'm guessing they need to be updated
also.

My need for this to conform is I have macros which rely on the forms
they expand to to detect syntax violations of some parts of my macros'
input, and my test programs (and fantasies of ultra meta programming)
need misuses of my macros to raise &syntax exceptions.

-- 
: Derick
----------------------------------------------------------------




More information about the Larceny-users mailing list