On Tuesday, October 02, 2012 18:21:30 H. S. Teoh wrote: > On Wed, Oct 03, 2012 at 03:07:14AM +0200, Andrej Mitrovic wrote: > > On 10/3/12, Jakob Ovrum <[email protected]> wrote: > > > writefln cannot be @safe if it has to support an unsafe format > > > specifier. It's "hidden" because it affects every call to writefln, > > > even if it doesn't use the unsafe format specifier. > > [...] > > Hmm, this seems to impose unnecessary limitations on @safe. I guess the > current language doesn't allow for a "conditionally-safe" tag where > something can be implicitly marked @safe if it's provable at > compile-time that it's safe?
The format string is a runtime argument, so nothing can be proven about it at compile time. If you want any kind of @safe inferrence, you need to use a template. If writefln took the format string as a template argument and generated different code (which was @safe or not depending on what it did) based on what was in the format string, then inferrence could take place, but otherwise no. - Jonathan M Davis
