While the new multiline sprintf %O looks snazzy, it will break code for everyone that uses it to ensure that a string contains no "bad" characters. Think log files, one line per entry. This needs to be reverted IMO as the effects on applications are hard to determine.
For reference: Pike v7.7 release 23 running Hilfe v3.5 (Incremental Pike Frontend)
"foo\nbar";
(1) Result: "foo\n" "bar"
That's already occupied by octal numbers, but I'm sure there is *some* letter or modifier left that could be used to convey this formatting preference.
I think that is the wrong way to go about things. I think it is better to make a more_human_readable_werror() that operates differently on %O, and use that one when presenting backtraces and hilfe-data.
From the Pike manual:
*! @value 'O' *! Any value, debug style. Do not rely on the exact formatting; *! how the result looks can vary depending on locale, phase of *! the moon or anything else the _sprintf method implementor *! wanted for debugging.
"Do not rely on the exact formatting"!
duh, right. hilfe in 7.6 gave me a strange backtrace that i neglected to look at closely.
While the new multiline sprintf %O looks snazzy, it will break code for everyone that uses it to ensure that a string contains no "bad" characters. Think log files, one line per entry. This needs to be reverted IMO as the effects on applications are hard to determine.
%O is for debug and NOTHING else!
Exactly what kind of code does people have that depends on %O output format? I use %O quite a bit, but only for printing debug info to stdout or similar.
Logging. Also sprintf %O and sscanf %O should be compatible.
I don't remember that discussion.
Not really, no, many string parsers does not consider "foo" "bar" "gazonk" to be one string.
then we maybe need something else that allows to output a mixed variable without having to check the type first.
often i want to print strings without having to worry if they are initialized, and i either use %O or %s with (string)foo, to make sure the 0 is casted to " " so that %s won't complain.
occaionally i want to print numbers without having to worry about the type. or what do i do if the variable is mixed?
currently %O is the only operator that can handle those.
maybe something like %M or %m would be nice, or, even better, some notation that reflects the types we have:
string|int foo; sprintf("%s|%i)", foo); // the above is not a good notation for this, but maybe this is: sprintf("%(si)", foo);
greetings, martin.
I prefer Nilssons suggestion of letting %O keep working like before, and add a new function or sprintf-operator that does "%O + extra formatting stuff" (which could include ellipsizing long sequences and so on as well).
pike-devel@lists.lysator.liu.se