Gambit is simply obeying your command! In the first invocation of gsc you are giving the -:s option which asks the compiler to assume the source code is using the standard Scheme syntax where '(path: ...) is a literal list whose first element is the *symbol* |path:|. But the procedure open-output-file is expecting a *keyword*. To make things clear look at this example:
--------------------------------------------------------- ;; File: "foo.scm"
(define (type-of x) (cond ((symbol? x) 'symbol) ((keyword? x) 'keyword) (else 'other)))
(pp (map type-of (list '|path:| 'path: (string->symbol "path:") (string->keyword "path")))) ---------------------------------------------------------
When compiled (with and without -:s) and executed, the program gives this output:
--------------------------------------------------------- % gsc foo ; gsi foo (symbol keyword symbol keyword) % gsc -:s foo ; gsi foo (symbol symbol symbol keyword) ---------------------------------------------------------
So if you want to write code that will work with and without -:s, then the keywords should be constructed explicitly with string->keyword.
Marc
On 2012-06-09, at 5:52 PM, David Rush wrote:
With Gambit 4.6.6, I am seeing decidedly different behavior for open-output-file between code compiled with gsc/gcc to run as a standalone executable and that same code compiled with gsc to run under gsi. The source code follows the body of the message, but the error from the standalone run tells the whole story, really. Specifically:
drr@dibbuk$ make target=gambit test/bug.gambit gsc -:s -link test/bug.Gambit gcc -I/home/drr/include test/bug.c test/bug_.c -o test/bug.gambit \ -L/home/drr/lib -lgambc -lm -lutil -ldl drr@dibbuk$ test/bug.gambit *** ERROR IN flog-file -- (Argument 1) STRING or port settings expected (open-output-file '(|path:| "test.flog" |create:| maybe |append:| #t))
drr@dibbuk$ gsc test/bug.Gambit drr@dibbuk$ gsi Gambit v4.6.6
(load "test/bug")
"/home/drr/git/heureka/framework/test/bug.o2"
(main (vector "this is a test")) (exit)
drr@dibbuk$ cat test.flog this is a test this is a test
Now the repeated lines in test.flog are expected from the gsi case because the code is effectively run twice, once upon load and once manually (as will be seen from the source below). So what is going on with the standalone execution? I am very puzzled.
the source code for bug.Gambit. This is the output of a preprocessor, so it looks a little strange, but it is really very straightforward.
(define _cons_23 cons) (define *flog-use-current-output-port* #f) (define *flog-use-current-error-port* #f)
(define flog-file (lambda (_file-name_38 _s_39) ((lambda (_f_40) (begin (display _s_39 _f_40) (newline _f_40) (if *flog-use-current-output-port* (display _s_39 (current-output-port))) (if *flog-use-current-error-port* (display _s_39 (current-error-port))) (close-output-port _f_40))) (open-output-file (_cons_23 (quote path:) (_cons_23 _file-name_38 (quote (create: maybe append: #t))))))))
(define main (lambda (_argv_38) (begin (flog-file "test.flog" "this is a test") )))
(main (command-line)) _______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list