digitalmars.D.learn - A array bug?
- taqya <taqya9 gmail.com> Jan 28 2009
- Ellery Newcomer <ellery-newcomer utulsa.edu> Jan 28 2009
- Stewart Gordon <smjg_1998 yahoo.com> Feb 04 2009
- Chris Nicholson-Sauls <ibisbasenji gmail.com> Feb 05 2009
- taqya <taqya9 gmail.com> Feb 05 2009
- Stewart Gordon <smjg_1998 yahoo.com> Feb 05 2009
- Chris Nicholson-Sauls <ibisbasenji gmail.com> Feb 05 2009
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:
char[] a = "a".dup; char[] b = "b".dup; writefln(a + b); //Error: Array operations not implemented
If so, the error informs you why you can't do that.
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:taqya wrote:
char[] a = "a".dup; char[] b = "b".dup; writefln(a + b); //Error: Array operations not implemented
If so, the error informs you why you can't do that.
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.
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-Sauls
Feb 05 2009
Chris Nicholson-Sauls Wrote:Stewart Gordon wrote:Ellery Newcomer wrote:taqya wrote:
char[] a = "a".dup; char[] b = "b".dup; writefln(a + b); //Error: Array operations not implemented
If so, the error informs you why you can't do that.
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.
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-Sauls
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?
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>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.
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-Sauls
Feb 05 2009









taqya <taqya9 gmail.com> 