Drafting and testing for PIP-0110 for format/2,3 threw up quite a number of inconsistencies between implementations. Here is a list of issues, together with my suggestion for how to resolve the issue in the PIP. Please comment if you have strong feelings…
| Topic | Alternatives | Suggestion |
|---|---|---|
| Types to allow for the format string | various | all text-like types: chars, codes, atom (and string if applicable) |
| Allow expressions in ~d, ~e, etc? | error/allow | allow, because widely implemented |
| Accept floats in ~d/D/r/R? | error/truncate/round | error, because conversion ambiguity |
| Accept integers in ~e/E/f/g/G? | error/allow | allow, but do not specify whether handled by coercion or special treatment |
| Allow expression in ~c ? | error/allow | allow for consistency, although not widely implemented |
| Accept expressions in arguments for ~* | error/allow | allow, but only integer expressions |
| Specify ~W format (with two arguments) as interface to write_term/3 | yes/no | yes, although not yet widely supported |
| Support ~@ format? | yes/no | no, requires meta-argument and redirecting the output stream |
| Support layout formats ~| ~t and ~+ ? | yes/no | yes - only useful with monospace fonts, but widely implemented and used |
| Treatment of supernumerary arguments? | error/ignore | error |
| Treatment of numeric parameter in formats that do not support one, e.g. ~3a | error/ignore | ignore, to allow extensions without violating the PIP |
| Accept non-atoms in ~a | error/accept | error, to avoid ambiguities with [ ] |
| Accept non-code-lists in ~s | error/accept | accept codes, chars, atom (and string if applicable) |
| Treatment of illegal radix (such as 0, 1, 37) in ~r | error/use default of 8 | error |
| Interpretation of ~0n | print nothing or 1 newline | print nothing |
| Treatment of numeric parameter in ~N, e.g. ~3N | error/ignore/interpret | ignore, since interpretation unclear |
| Interpret numeric parameter as print depth in ~w ~q ~k (Paulo’s suggestion) | yes/no | no, meaningful only for ~w, not widely implemented, and expressible via ~W |
Other discrepancies in implementations concern the error terms thrown, but I’m inclined to leave this unspecified in the PIP.