[gambit-list] Puzzlement (different behavior of compiled code)

Mikael mikael.rcv at gmail.com
Sun Jun 10 09:31:43 EDT 2012


Uh this is funny:

(open-output-file '(|path:| "test.flog" |create:| maybe |append:| #t))

look there, there's  |:s around the keywords. This means they're *not*
actually keywords but *symbols* that kind of look like keywords.

I suppose this is the cause of the error you encountered.

Tried to reproduce your error on 4.6.2:

$ cat a.scm
(write (cons abcde: 123))
$ gsi a.scm
(abcde: . 123)$ gsc -exe a.scm
$ ./a
(abcde: . 123)

I.e. does not reproduce your results. Not one character of the involved
Gambit code ought to have been changed in the current version since 4.6.2.

Do you compile this code just with gsc filename.scm  or (compile-file
"filename.scm") or do you have some preprocessor on it?

Do you see any other reasons for why this occured?



2012/6/10 David Rush <kumoyuki at gmail.com>

> 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 at 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 at 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 at dibbuk$ gsc test/bug.Gambit
> drr at 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 at 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 at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://webmail.iro.umontreal.ca/pipermail/gambit-list/attachments/20120610/f68adc26/attachment.html 


More information about the Gambit-list mailing list