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:29

_
IHBT

Name: Anonymous 2011-03-12 20:32

No, really. I don't know how to do this

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]

Name: Anonymous 2011-03-12 22:37

>>4
I would have expected Schemers do know way better than that.

Name: Anonymous 2011-03-13 3:04

What kind of shit is that? You're telling me that with R5RS you can't open an output file if it already exists? There has to be a way, otherwise fuck scheme. Can you at least detect if a file exists, and if it does, delete it?

Name: Anonymous 2011-03-13 9:00

>>6
No, what I said is that it is that what open-output-file does is unspecified if the file already exists. It may replace it, it may append to it, it can send it to the FBI, it can throw an error, it can BSOD... Which you would know IF YOU READ THE FUCKING STANDARD. It is also why A) NO-ONE uses plain R5RS B) NO-ONE uses plain R5RS and C) NO-ONE USES PLAIN R5RS.
Can you at least detect if a file exists, and if it does, delete it?
HAHAHAHAHAHAHAHAHAHA
No, again, READ THE FUCKING STANDARD. file-exists? and delete-file were only standardised in R6RS.

And people tell me what a travesty R6RS is, maybe so, but I can write useful and portable programs in it.

Name: Anonymous 2011-03-13 9:36

>>7
Portable between inexistent implementations, yes.

Name: Anonymous 2011-03-13 10:49

>>8
There are 6-8 implementations of R6RS

Name: Anonymous 2011-03-13 12:17

>>9
Racket
ikarus
larceny
ypsilon
mosh
chez
ironscheme(not quite)
biwa(really not)
guile and kawa(flirting with it)

Name: Anonymous 2011-03-13 12:22

I'm not using R5RS by choice, it's for a CS class.

Name: Anonymous 2011-03-13 12:26

>>11
Do your own homework then, ``faggot".

Name: Anonymous 2011-03-13 12:30

I wasn't asking anyone to do it for me, I just needed clarification on that one part. Now I just need to write a
set-equal? function :(

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