And what expectations does fmt have?
Chris
--
Chris "allusive" Dollin
Sometimes, when you make a programming error, it doesn't necessarily
mean the language should change. It just means you should aim to be a
little more careful.
/$0.02
It's a problem with any function that accepts a string.
Should they all be required to hand you back the
string upon request? What about things that aren't
strings? I'm sympathetic to running into bugs, but
you're asking to augment a single API with debugging
functionality already present in the programming language.
Variables and print statements already let you replace:
var reg = regexp.MustCompile(fmt.Sprintf(....))
with
func init() {
s := fmt.Sprintf(....)
fmt.Println("COMPILING", s)
reg = regexp.MustCompile(s)
}
Russ
leaving the error in-band only leads to subtle bugs such as the one illustrated
by Archos.
i realise i'm in a minority on this though.
The real right solution is to find a way for the compiler or some
other tool to help, analogous to - but not the same approach taken by
- the #pragmas in the Plan 9 C compiler.
-rob
This sounds like the sort of thing worth adding to golint, but: does the
compiler do any optimizations on functions like fmt.Printf? If so, it
would be logical to deal with it there.
I'm not suggesting any plan of action, just noting that when the right
path is clear, even though its route is not, the wrong path is to be
avoided.
-rob