(Ab)use of IOContext for fine-grained output control

Is it considered a reasonable use of IOContext to define a large number of settings that control output in a fine manner? I’m considering settings such as :serialcomma => true, decimalpoint => ".", and similar, and wonder if this is perhaps overloading the capacities of IOContext. If so, what would be a reasonable alternative to express this, while still tying into the Julia output system?

1 Like

I think the current recommendation here is that if you know exactly how your output should be formatted, it is more sensible to compose your own IO layout using @printf or Formatting.jl or similar to get exactly that output you intended, rather than trying to configure the output via the recursive IO argument.

1 Like

The issue with that is that you may call a formatting function which in turn calls … a function which prints a number, potentially with separators. How do you pass options to that inner formatting routine? Using the IOContext object seems like a not-completely-insane way to do it, but I haven’t thought it through.

1 Like