November 18, 2005 Bug? Are wchar[] and dchar[] treated differently? | ||||
---|---|---|---|---|
| ||||
Fedora Core 4 Linux, I compile this: import std.stream; void main() { char[] c = "Saatana perkele"c; wchar[] w = "Saatana perkele"w; dchar[] d = "Saatana perkele"d; File of1 = new File; File of2 = new File; File of3 = new File; of1.create("/tmp/1.txt"); of2.create("/tmp/2.txt"); of3.create("/tmp/3.txt"); of1.write(c); of1.write(w); of1.write(d); // error line 19 of2.write(w); of2.write(d); // error line 22 of2.write(c); of3.write(d); // error line 25 of3.write(c); of3.write(w); of1.close(); of2.close(); of3.close(); } And I get the following compiler errors: $ dmd outtest2.d outtest2.d(19): function std.stream.Stream.write (ubyte[]) does not match argument types (dchar[]) outtest2.d(19): cannot implicitly convert expression (d) of type dchar[] to wchar[] outtest2.d(22): function std.stream.Stream.write (ubyte[]) does not match argument types (dchar[]) outtest2.d(22): cannot implicitly convert expression (d) of type dchar[] to wchar[] outtest2.d(25): function std.stream.Stream.write (ubyte[]) does not match argument types (dchar[]) outtest2.d(25): cannot implicitly convert expression (d) of type dchar[] to wchar[] I would have expected complaints about maybe d and w, but not about d only. (And I would have wished no complaints at all, but that's not reasonable yet.) |
November 18, 2005 Re: Bug? Are wchar[] and dchar[] treated differently? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Georg Wrede | On Fri, 18 Nov 2005 08:51:41 +0200, Georg Wrede <georg@nospam.org> wrote:
> Fedora Core 4 Linux, I compile this:
>
> import std.stream;
>
> void main()
> {
> char[] c = "Saatana perkele"c;
> wchar[] w = "Saatana perkele"w;
> dchar[] d = "Saatana perkele"d;
>
> File of1 = new File;
> File of2 = new File;
> File of3 = new File;
>
> of1.create("/tmp/1.txt");
> of2.create("/tmp/2.txt");
> of3.create("/tmp/3.txt");
>
> of1.write(c);
> of1.write(w);
> of1.write(d); // error line 19
>
> of2.write(w);
> of2.write(d); // error line 22
> of2.write(c);
>
> of3.write(d); // error line 25
> of3.write(c);
> of3.write(w);
>
> of1.close();
> of2.close();
> of3.close();
> }
>
> And I get the following compiler errors:
>
> $ dmd outtest2.d
>
> outtest2.d(19): function std.stream.Stream.write (ubyte[])
> does not match argument types (dchar[])
> outtest2.d(19): cannot implicitly convert expression (d)
> of type dchar[] to wchar[]
> outtest2.d(22): function std.stream.Stream.write (ubyte[])
> does not match argument types (dchar[])
> outtest2.d(22): cannot implicitly convert expression (d)
> of type dchar[] to wchar[]
> outtest2.d(25): function std.stream.Stream.write (ubyte[])
> does not match argument types (dchar[])
> outtest2.d(25): cannot implicitly convert expression (d)
> of type dchar[] to wchar[]
>
> I would have expected complaints about maybe d and w, but not about d only. (And I would have wished no complaints at all, but that's not reasonable yet.)
It appears there is no overload for dchar[] in std.stream, I see:
// writes a string, together with its length
void write(char[] s) {
write(s.length);
writeString(s);
}
// writes a Unicode string, together with its length
void write(wchar[] s) {
write(s.length);
writeStringW(s);
}
but no write method for dchar[].
There is no writeStringD or writeLineD either.
Regan
|
Copyright © 1999-2021 by the D Language Foundation