mthom / scryer-prolog

A modern Prolog implementation written mostly in Rust.
BSD 3-Clause "New" or "Revised" License
1.93k stars 116 forks source link

library(pio): phrase_to_file does not accept the file mode #2430

Open stevemolloy opened 6 days ago

stevemolloy commented 6 days ago

Could phrase_to_file in library(pio) be extended to also accept the file mode? I would like the option to open the file in append mode.

triska commented 5 days ago

I think it's possible to add this, though could you please first expand on the intended use case? There may be a better solution for it that uses only existing constructs.

stevemolloy commented 3 days ago

Hi triska. My use case is as follows. I am parsing a json file into a number of prolog predicates, and I would like to write these to file. It would be simpler to append each of these as they are encountered, rather than having to build the entire character string and save that to file.

triska commented 3 days ago

As one way to implement this with the current facilities, you can collect all predicates into a list (for instance, with findall/3), and describe the list of characters corresponding to that list.