The purpose of this Package is to extend the stdlib/Printf package with further format options. If finished, it should be able to replace stdlib/Printf.
Rationale: When format strings are translated to other natural languages, sometimes the order of the variable arguments must be changed.
@sprintf "%2&d %1&d" 41 42 results in
sprintfmay be used instead of macros
Rationale: The format strings may be available in string variables or the result of macro expansions of strings with embedded interpolation. This is not supported by the macro-implementation.
printf(@tr"Name: %s Salary: %.2f", a, b) assumung tr_str is a macro which replaces the input with another language.
format(::String) -> Function(::IO, args...)
The format string is represented as a function, with appropriate argument number and type. The first argument is an output device. For each different format string, the function is generated once by parsing the format string. The code block of the function is the same as generated for the macros. The permanent storage of the functions allows to restrict the format-parsing to once per runtime as is the case for macro implementation.
form_1 = format("%20s %g"); ... ; form_1(STDOUT, "hello", 99.8)
over 3 years ago