[plt-scheme] writing to files
At Mon, 21 Jul 2008 14:52:40 -0400, "Marco Morazan" wrote:
> Would someone be kind enough to point me in the right direction?
>
> [...]
>
> (define (w2file c filename)
> (let ((file (open-output-file
> (string-append
> "C:/Users/SHU-USER/Documents/Test/"
> (symbol->string filename)
> ".txt")
> #:mode 'text
> #:exists 'replace)))
> (begin
> (write2file c file)
> (close-output-port file)
> )))
You've hit the awful R5RS/EoPL bug in 4.0.2 where `begin' in a
internal-definition position gets evaluated twice. Removing the
`begin's makes the program work correctly.
This bug is fixed in SVN for the 4.0.3 or 4.1 release (whichever the
next one turns out to be).
Matthew