evyatar2013
2021-2-9 20:10:30

Hey all, This is a Rosette specific question, but I wonder if anyone here has experience with the language and can help make sense of this behavior: Code: #lang rosette (define (what value) (for/all ([w value]) (displayln w))) (define-symbolic b boolean?) Behavior: > (what (if b 1 2)) (ite b 1 2) > (what (if b "a" "b")) a b > (union? (if b "a" "b")) #t > (union? (if b 1 2)) #f


evyatar2013
2021-2-9 20:13:58

Oh I answered my own question. (if b 1 2) is a solveable type (i.e integer?) so it isnt a union and therefor not expanded by for/all


sorawee
2021-2-9 20:18:30

yes


jestarray
2021-2-9 20:19:36

what does ’truncate mean in call-with-ouputfile ?


jestarray
2021-2-9 20:19:43

like it removes the whitespace n stuf?


sorawee
2021-2-9 20:19:45

There’s a hidden feature in for/all. I don’t recall its syntax exactly, but it looks like:

(for/all ([w value #:exhaustive]) body) This will additionally split on ite.


evyatar2013
2021-2-9 20:20:21

yup! I was just about to ask what #:exhuastive does under the hood and what the consequences of using it are :stuck_out_tongue:


sorawee
2021-2-9 20:20:53

There’s also another hidden feature, called concrete list


sorawee
2021-2-9 20:21:10

(for/all ([w value (list 1 2)]) body)


sorawee
2021-2-9 20:21:32

This will split over two possibilities: value = 1 and value = 2


evyatar2013
2021-2-9 20:22:05

that’s awesome!


sorawee
2021-2-9 20:23:34

No, it means “empty” the file quickly before performing the write


evyatar2013
2021-2-9 20:23:38

thanks @sorawee


sorawee
2021-2-9 20:23:44

np!


jestarray
2021-2-9 20:51:55

what about replace?


sorawee
2021-2-9 20:55:15

It removes the file entirely I think, and then create a new one. IIUC, the identity of the file might not be preserved (I have no idea how filesystem works, but I guess it has something to do with inode or something like that).



sorawee
2021-2-9 21:03:11

Ah, I was handwavy when I talked about “identity”. A more concrete thing to talk about is the metadata attached to the file, like permission.


sorawee
2021-2-9 21:03:24

By using truncate, the metadata would be preserved


sorawee
2021-2-9 21:03:40

By using replace, metadata might not be preserved.