Axel> The other "easy" way to reduce impact here is to reduce the use of
Axel> nsTextFormatter, or create a replacement that doesn't crash. L20n
Axel> would be one, or maybe there's C++ template stuff that can "taint"
Axel> values with their original types.

Tom> I don't think there is a compile-time solution to this part of problem,
Tom> because the substitution is done at runtime.

Tom> I think what is needed for this problem is a runtime check to verify
Tom> that the translated format string is consistent with the "primary" one.

I was thinking about this more and I realized you were correct.

If the formatter is a variadic template function, then it's possible to
ensure at runtime that a particular format option corresponds to the
type of the actual argument.

This approach would supply runtime safety.  Instead of crashing, the
formatter could return an error.

I think compile-time checking is also worth doing.  Maybe it's even
possible using some scary combination of constexpr and variadic
templates; fun!, though I imagine a compiler plugin is simpler.

Tom
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to