diff --git a/CHANGELOG.md b/CHANGELOG.md index 14c703554..c647f9a39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ and this project does not currently adhere to a particular versioning scheme. - Add local definitions to functional syntax. - Add repeated field name error message. - Add `Math` builtin functions. ([#570][gh-570]) +- Add primitive file IO function `IO/FS/flush`. ([#598][gh-598]) ## [0.2.35] - 2024-06-06 @@ -387,3 +388,4 @@ and this project does not currently adhere to a particular versioning scheme. [gh-514]: https://github.com/HigherOrderCO/Bend/issues/514 [gh-544]: https://github.com/HigherOrderCO/Bend/pull/544 [Unreleased]: https://github.com/HigherOrderCO/Bend/compare/0.2.36...HEAD +[gh-598]: https://github.com/HigherOrderCO/Bend/issues/598 diff --git a/docs/builtins.md b/docs/builtins.md index 07ac88951..f15291dbf 100644 --- a/docs/builtins.md +++ b/docs/builtins.md @@ -429,6 +429,16 @@ Moves the current position of the file with the given `file` descriptor to the g Returns nothing (`*`). +#### File flush + +```python +def IO/FS/flush(file) +``` + +Flushes the file with the given `file` descriptor. + +Returns nothing (`*`). + ## Numeric operations ### log diff --git a/src/fun/builtins.bend b/src/fun/builtins.bend index b89f6bd97..cbae7c78a 100644 --- a/src/fun/builtins.bend +++ b/src/fun/builtins.bend @@ -128,6 +128,7 @@ IO/FS/close file = (IO/Call IO/MAGIC "CLOSE" file @x (IO/Done IO/MAGIC x)) IO/FS/read file num_bytes = (IO/Call IO/MAGIC "READ" (file, num_bytes) @x (IO/Done IO/MAGIC x)) IO/FS/write file bytes = (IO/Call IO/MAGIC "WRITE" (file, bytes) @x (IO/Done IO/MAGIC x)) IO/FS/seek file offset mode = (IO/Call IO/MAGIC "SEEK" (file, (offset, mode)) @x (IO/Done IO/MAGIC x)) +IO/FS/flush file = (IO/Call IO/MAGIC "FLUSH" file @x (IO/Done IO/MAGIC x)) ### Always available files IO/FS/STDIN = 0