Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

~! in format will force-output #999

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/reference/std/format.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ in [SRFI 48](https://srfi.schemers.org/srfi-48/srfi-48.html).
-> string
```


Formats the arguments to a string using the supplied format specifier.

::: warning Differences with SRFI 48
Expand All @@ -25,6 +24,7 @@ Formats the arguments to a string using the supplied format specifier.
- ~f/~F means "float" and does non-exp fp (C-style %f more or less)
- ~r/~R means "repr" and works with `:std/misc/repr` and the `:pr` method
- ~w{spec} does generic fixed width
- ~! does force-output (inspired by OCaml)
- not implemented: ~& ~H wtfs
:::

Expand Down
4 changes: 4 additions & 0 deletions src/std/format.ss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
;; ~f/~F means "float" and does non-exp fp (C-style %f more or less)
;; ~r/~R means "repr" and works with `:std/misc/repr` and the `:pr` method
;; ~w{spec} does generic fixed width
;; ~! does force-output (inspired by OCaml)
;; not implemented: ~& ~H wtfs
;; TODO: ~g/~e for C-style %g/%e

Expand Down Expand Up @@ -161,6 +162,9 @@
(defdispatch-q (#\_)
(write-char #\space))

(defdispatch-q (#\!)
(force-output))
fare marked this conversation as resolved.
Show resolved Hide resolved

;; recursive format
(defdispatch (#\? #\k #\K)
(lambda (_ K xi rest)
Expand Down