digitalmars.D.learn - A array bug?
- taqya (11/11) Jan 28 2009 Hi,i write this code. then d compiler is shutdown.
- Ellery Newcomer (6/18) Jan 28 2009 '+' implies you're trying to add "a" and "b" together e.g.
-
Stewart Gordon
(10/15)
Feb 04 2009
-
Chris Nicholson-Sauls
(6/23)
Feb 05 2009
Suggest: Array operation '
' not implemented for type []. - taqya (9/36) Feb 05 2009 import std.stdio;
- Stewart Gordon (7/12) Feb 05 2009 It doesn't quite work like that. AIUI the only supported way of using
- Chris Nicholson-Sauls (5/15) Feb 05 2009 Just double-checked the spec, and yes, array ops are triggered by a
Hi,i write this code. then d compiler is shutdown. Is it a array bug? //Digital Mars D Compiler v2.014 (windows) import std.stdio; int main() { char[] a = "a".dup; char[] b = "b".dup; writefln(a + b); //Error: Array operations not implemented return 0; }
Jan 28 2009
taqya wrote:Hi,i write this code. then d compiler is shutdown. Is it a array bug? //Digital Mars D Compiler v2.014 (windows) import std.stdio; int main() { char[] a = "a".dup; char[] b = "b".dup; writefln(a + b); //Error: Array operations not implemented return 0; }'+' implies you're trying to add "a" and "b" together e.g. (char)((int) 'a' + (int) 'b') If so, the error informs you why you can't do that. If you're trying to concatenate, use the '~' operator. assert ( "a" ~ "b" == "ab" );
Jan 28 2009
Ellery Newcomer wrote:taqya wrote:<snip><snip>char[] a = "a".dup; char[] b = "b".dup; writefln(a + b); //Error: Array operations not implementedIf so, the error informs you why you can't do that.<snip> Except that it doesn't. "Array operations not implemented" is a leftover from a previous version of the D spec. Nowadays array operations _are_ implemented, but the language doesn't support this particular use thereof. So the bug is that the error message is badly written. Stewart.
Feb 04 2009
Stewart Gordon wrote:Ellery Newcomer wrote:Suggest: Array operation '<OP>' not implemented for type <T>[]. Where <OP> is here '+' and <T> is here char. And possibly catch the particular case of char[] and suggest '~', since it is probably the single most common mistake in this area. -- Chris Nicholson-Saulstaqya wrote:<snip><snip>char[] a = "a".dup; char[] b = "b".dup; writefln(a + b); //Error: Array operations not implementedIf so, the error informs you why you can't do that.<snip> Except that it doesn't. "Array operations not implemented" is a leftover from a previous version of the D spec. Nowadays array operations _are_ implemented, but the language doesn't support this particular use thereof. So the bug is that the error message is badly written. Stewart.
Feb 05 2009
Chris Nicholson-Sauls Wrote:Stewart Gordon wrote:import std.stdio; void main() { char[] a = "a".dup; char[] b = "b".dup; writefln(a+b); } I compile the code on Windows. Then pop up a message 'dmd.exe has stopped working'. my personal situation?Ellery Newcomer wrote:Suggest: Array operation '<OP>' not implemented for type <T>[]. Where <OP> is here '+' and <T> is here char. And possibly catch the particular case of char[] and suggest '~', since it is probably the single most common mistake in this area. -- Chris Nicholson-Saulstaqya wrote:<snip><snip>char[] a = "a".dup; char[] b = "b".dup; writefln(a + b); //Error: Array operations not implementedIf so, the error informs you why you can't do that.<snip> Except that it doesn't. "Array operations not implemented" is a leftover from a previous version of the D spec. Nowadays array operations _are_ implemented, but the language doesn't support this particular use thereof. So the bug is that the error message is badly written. Stewart.
Feb 05 2009
Chris Nicholson-Sauls wrote: <snip>Suggest: Array operation '<OP>' not implemented for type <T>[]. Where <OP> is here '+' and <T> is here char.It doesn't quite work like that. AIUI the only supported way of using array operations is assigning the result to an array slice, which this isn't.And possibly catch the particular case of char[] and suggest '~', since it is probably the single most common mistake in this area.Maybe.... Stewart.
Feb 05 2009
Stewart Gordon wrote:Chris Nicholson-Sauls wrote: <snip>Just double-checked the spec, and yes, array ops are triggered by a slice appearing as an lvalue. So, a different error message entirely is warranted. -- Chris Nicholson-SaulsSuggest: Array operation '<OP>' not implemented for type <T>[]. Where <OP> is here '+' and <T> is here char.It doesn't quite work like that. AIUI the only supported way of using array operations is assigning the result to an array slice, which this isn't.
Feb 05 2009