D - [inconsistancy] std.stream
- Scott Egan (11/11) Apr 19 2004 I noticed that the std.stream has an overloaded write method that handle...
- Ben Hinkle (5/22) Apr 19 2004 If it was overloaded dmd complains that it can't resolve
-
Scott Egan
(6/28)
Apr 20 2004
Oh... true
- Matthew (10/32) Apr 20 2004 handles
I noticed that the std.stream has an overloaded write method that handles all sorts of data including char & wchar, and yet for the writeLine and writeString methods, rather than overload them for char[] and wchar[], two different versions are provided. Is this such a good thing? Should not it just be: void writeLine(char[] s) void writeLine(wchar[] s) void writeString(char[] s) void writeString(wchar[] s) ???
Apr 19 2004
Scott Egan wrote:I noticed that the std.stream has an overloaded write method that handles all sorts of data including char & wchar, and yet for the writeLine and writeString methods, rather than overload them for char[] and wchar[], two different versions are provided. Is this such a good thing? Should not it just be: void writeLine(char[] s) void writeLine(wchar[] s) void writeString(char[] s) void writeString(wchar[] s) ???If it was overloaded dmd complains that it can't resolve writeString("a string literal") If that behavior changed then I'd say go ahead and overload. Otherwise it is pretty annoying to have to always cast string literals at the call site.
Apr 19 2004
Oh... true <gush> "Ben Hinkle" <bhinkle4 juno.com> wrote in message news:c60g49$2o9m$1 digitaldaemon.com...Scott Egan wrote:handlesI noticed that the std.stream has an overloaded write method thattwoall sorts of data including char & wchar, and yet for the writeLine and writeString methods, rather than overload them for char[] and wchar[],isdifferent versions are provided. Is this such a good thing? Should not it just be: void writeLine(char[] s) void writeLine(wchar[] s) void writeString(char[] s) void writeString(wchar[] s) ???If it was overloaded dmd complains that it can't resolve writeString("a string literal") If that behavior changed then I'd say go ahead and overload. Otherwise itpretty annoying to have to always cast string literals at the call site.
Apr 20 2004
"Ben Hinkle" <bhinkle4 juno.com> wrote in message news:c60g49$2o9m$1 digitaldaemon.com...Scott Egan wrote:handlesI noticed that the std.stream has an overloaded write method thattwoall sorts of data including char & wchar, and yet for the writeLine and writeString methods, rather than overload them for char[] and wchar[],isdifferent versions are provided. Is this such a good thing? Should not it just be: void writeLine(char[] s) void writeLine(wchar[] s) void writeString(char[] s) void writeString(wchar[] s) ???If it was overloaded dmd complains that it can't resolve writeString("a string literal") If that behavior changed then I'd say go ahead and overload. Otherwise itpretty annoying to have to always cast string literals at the call site.This should be changed. Either the user needs to cast - which seems eminently reasonable to me - or maybe the compiler can be made to detect whether the string literal contains any character sequences that would require wchar[], and default to char[] if not. [Caveat: I'm a little off-the-cuff on the second option.]
Apr 20 2004