I would like to illustrate the manual's Module Warning (in section
11.1.3)
that programs mixing SCHEME and SCSH imports may feature awkward errors
due
to extensions of basic procedures. This one puzzled me considerably
(in its
wild form, until I realised what I was doing, i.e. not taking heed of
the
manual as I should) --
In scsh-0.6.4, ,config ,load the code below, touch foo.dat in the
working directory, then ,in breakit (break) -- resulting in the
Error: Bad argument
#{Input-port #{Input-channel "foo.dat"}}
#{Procedure 12486 (open-fdport? in scsh-level-0)}
#{Procedure 12497 (port->fdes in scsh-level-0)}
The structure is essential. The bug wouldn't bite in ENDIAN itself,
if you were to define and call BREAK there: in BREAKIT we import OPEN-
INPUT-FILE from SCHEME, in ENDIAN from (SCHEME-WITH-)SCSH.
(define-structure breakit (export )
(open endian scheme)
(begin
(define (break)
(endian-port-setpos (make-endian-port (open-input-file "foo.dat")
#t)
0))
))
(define-structure endian (export make-endian-port
endian-port-setpos)
(open scheme-with-scsh)
(begin
(define make-endian-port cons)
(define endian-port-port car)
(define (endian-port-setpos eport pos)
(seek (endian-port-port eport) pos))
))
rthappe
|