[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] programs and cond-expand



On Fri, Oct 25, 2013 at 11:06 AM, Jim Rees <jimreesma@x> wrote:
How about (eval '(lambda () expr))  -- if an error happens, it can only be compile-time.

Good point, all the eval solutions should be wrapping
expr in a lambda.

This doesn't change the fact that you still need eval :/




On Thu, Oct 24, 2013 at 8:48 PM, Alex Shinn <alexshinn@x> wrote:
On Fri, Oct 25, 2013 at 12:53 AM, Michael Montague <mikemon@x> wrote:
My reader includes location information when it reads identifiers and
quote strips all that out. I want that to be part of the tests and I
want to be able to test for specific errors. I will put more thought
into it and figure out a way to make my tests work in (chibi test).

It's not really possible without implementation-specific
extensions, because the error is happening at compile
time, and there's no standard way to catch compile-time
errors.

You could write a low-level macro that evaluates it's body:

(define-syntax test-syntax
  (er-macro-transformer
    (lambda (expr rename compare)
      (guard (else (exn '(test-assert "syntax bad" #f)))
        (eval expr)
        '(test-assert "syntax ok" #t)))))

and maybe preserve the source info there, but it's still
just falling back on eval.

As an implementation-specific extension you could provide
a syntax-guard form which can catch macro errors, which
would be a cleaner solution.

-- 
Alex


_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports



_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports