3 ms·
"pure" prolog I/O is every bit as pure as Haskell pure I/O, which is ... not very much and in a hand-wavy sort of way. My understanding is that it basically mea
by rscho 4y ago
"pure" prolog I/O is every bit as pure as Haskell pure I/O, which is ... not very much and in a hand-wavy sort of way. My understanding is that it basically means "either it corresponds to the spec, or it fails". At first, it seems trivial and a strange point of pride to have. Until you realize that most languages actually don't have anything built-in to do that, and must resort to some sort of parser. At which point, the data is already past your I/O gateway and may lead to unpredictable effects in your program. This is not an academic opinion, just my 2c.
- YeGoblynQueenne 4y agoThanks for taking the time to reply! I appreciate your 2c. I guess my confusion about pure I/O stems from the documentation of phrase_from_file/2 in SWI-Prolog. The documentation says the predicate is for pure I/O and how it was implemented, and by whom, but it doesn't say what pure I/O is, and why it is needed. I guess the information is somewhere in one (or more) of the canonical Prolog textbooks, which I've only read several years ago (though multiple times over, each). I have to confess also I'm not much of a purist. My Prolog code looks like bog standard imperative code where I feel it doesn't really matter (e.g. I don't have any prejudice about setof/3 or maplist/2 over findall/3), and I guess file I/O is one of those cases. Anyway, thanks again, for your links and explanation. I owe you a quantum of knowledge :)