Method lfun::_sprintf()
- Method _sprintf
string_sprintf(intconversion_type,mapping(string:int)|voidparams)- Description
Sprintf callback.
This method is called by sprintf() to print objects. If it is not present, printing of the object will not be supported for any conversion-type except for the %O-conversion-type, which will output
"object".- Parameter
conversion_type One of:
'b'Signed binary integer.
'd'Signed decimal integer.
'u'Unsigned decimal integer.
'o'Signed octal integer.
'x'Lowercase signed hexadecimal integer.
'X'Uppercase signed hexadecimal integer.
'c'Character. If a fieldsize has been specified this will output the low-order bytes of the integer in network byte order.
'f'Float.
'g'Heuristically chosen representation of float.
'G'Like %g, but uses uppercase E for exponent.
'e'Exponential notation float.
'E'Like %e, but uses uppercase E for exponent.
's'String.
'O'Any value (debug style).
't'Type of the argument.
- Parameter
params Conversion parameters. The following parameters may be supplied:
"precision":intPrecision.
"width":intField width.
"flag_left":int(1..1)Indicates that the output should be left-aligned.
"indent":intIndentation level in %O-mode.
- Returns
Is expected to return a string describing the object formatted according to
conversion_type.- Note
_sprintf() is currently not called for the following conversion-types:
'F'Binary IEEE representation of float (%4F gives single precision, %8F gives double precision.)
- Note
This function might be called at odd times, e.g. before lfun::create has been called or when an error has occurred. The reason is typically that it gets called when a backtrace is being formatted to report an error. It should therefore be very robust and not make any assumptions about its own internal state, at least not when
conversion_typeis'O'.- Note
It's assumed that this function is side-effect free.
- See also