Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Scheme/Racket output-file

Name: Anonymous 2011-03-12 20:17

hey, I have a question about the scheme programming language R5RS(now called racket or something)

All I want to do is open an output file. This seems easy. This is what I'm doing:

(define out_file (open-output-file out_file_n))

Where out_file_n is the name of the output file as a string. This works, however if the output file already exists, it throws an error. How do I open an output file, and if it already exists, a new one replaces it?

Thanks!

Name: Anonymous 2011-03-12 20:36

The answer is READ THE FUCKING DOCUMENTATION.

OK, the real answer is it depends on which "language" you are using in racket.
a) #lang R5RS - opening on an existing file is unspecified. Basically your out of luck as far as portability goes
b) #lang R6RS - which I'm most familiar with, you would need to use the open-file function with the no-fail option.
c) #lang racket - pass the 'replace option to the #:exists keyword


For those of you who correctly think this is a joke, I agree with you. But the R5RS was underspecified, and every fucking implementation decides to be incompatible in their own way. If R7RS doesn't bring more unity to the Scheme community I'm going to shoot certain members in the face. [/rant]

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List