Am Sun, 31 Aug 2014 01:09:32 +0000 schrieb "Ola Fosheim Grøstad" <[email protected]>:
> I've got some questions: > > How does logging interact with pure? You need to be able to log > in pure functions. How do you come to that conclusion? Purity is a synonym for _not_ having side effects. That said - as usual - "debug" statements allow you to punch a hole into purity. > […] > > Is logf() needed? Can't you somehow detect that the string is an > immutable string literal with string formatting characters? 1) The first argument does not need to be a literal. 2) Checking the first argument for formatting chars slows the system down. 3) If you want to log a regular string, e.g. an incoming HTTP request or something that contains formatting symbols, log() would throw an exception about a missing second argument. This in turn could become a DOS vulnerability. Other than that, you could create an additional log function that only accepts compile-time known formatting strings as a CT argument and verifies the runtime argument types at the same time. -- Marco
