This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Using the Unit Test Srfi from inside a library definition



On 03/29/2015 07:39 PM, Jeff Gonis wrote:
However if I try to define my test inside a define-library form I get
the following error message:
/dev/stdin:79:7: improper list (circular or dotted) is not allowed here

The minimal library example is as follows:
(define-library (testlib)
   (export test-suite)
   (import (scheme base)
              (srfi 64))
   (begin
     (define (test-suite)
       (test-begin "temp")
       (test-end "temp"))))

As far as I can tell, there shouldn't be any difference here,
except that the test-begin and end are define inside a library.

I checked in a fix for this - it should work now.

The issue is that the default Kawa top-level environment has a number of
predefined bindings, while the body of a define-library only has the
bindings you explicitly import.  The problem is when testing.scm (i.e.
he implementation of srfi 64) is compiled.  Any bindings that are not
explicitly imported are resolved in the default Kawa top-level, which
normally works fine.  Consider a macro that expands to a form that references
various standard Scheme forms.  If the bindings haven't been hygienically
imported when compiling testing.scm, then the Kawa compiler will normally
look for bindings in the default top-level environment dynamic environment
- which is disabled when processing the body of a define-library.

The particular error message you saw is because the binding for quote
is missing, so Kawa processes quote as if it were a call to an unknown
function.

The fix is (basically) to (import (scheme base)) when compiling testing.scm.
This provides hygienic bindings for names used in expanded macros.
(It was a little more complicated than that, mainly because test-begin
is magic in the default top-level, causing an auto-import.)

 I may have missed something incredibly simple though and if so my apologies
for taking up your time.

Nope, it was a Kawa bug that needed to be fixed.  Thanks for the
simple test-case.

A lot of these errors were fixed last year (largely thanks to testing by
Seth Alves), but there are probably more remaining.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]