Re: writef %d of string

2011-12-04 Thread Stewart Gordon
On 02/12/2011 03:19, bearophile wrote: Stewart Gordon: It's perfectly legal code, If that code is legal, then in my opinion it's the rules of the language that are wrong and in need to be changed :-) You mean all programming languages should support CTFE for argument validation? What if

Re: writef %d of string

2011-12-04 Thread bearophile
Stewart Gordon: You mean all programming languages should support CTFE for argument validation? This is not necessary, and it's not sufficient... What if the format string isn't even known at compile time in the first place? In this case the format string validation is done at run-time.

Re: writef %d of string

2011-12-01 Thread Stewart Gordon
On 12/10/2011 23:41, bearophile wrote: This code, that a sane language/language implementation refuses at compile-time, runs: It's perfectly legal code, so the best a compiler can correctly do is give a warning. Some C(++) compilers understand printf and will warn if the format string

Re: writef %d of string

2011-12-01 Thread bearophile
Stewart Gordon: It's perfectly legal code, If that code is legal, then in my opinion it's the rules of the language that are wrong and in need to be changed :-) Some C(++) compilers understand printf and will warn if the format string doesn't match the arguments, but even this is rare AIUI.

writef %d of string

2011-10-12 Thread bearophile
This code, that a sane language/language implementation refuses at compile-time, runs: import std.stdio; void main() { writefln(%d, hello); } And it outputs: ['h', 'e', 'l', 'l', 'o'] Is this good/expected/acceptable/buggy? Bye, bearophile

Re: writef %d of string

2011-10-12 Thread Andrej Mitrovic
That's a sweet trick right there. I get different results but I guess this is due to new std.format changes: [104, 101, 108, 108, 111]