www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - new static array

reply "anonymous" <a b.cd> writes:
Hello,

I tried to send a string[4] with std.concurrency:

import std.concurrency;
import std.stdio;
void fun() {
	receive((string[4] data) { writeln(data);});
}

void main() {
	string[4] data;
	auto tid = spawn(&fun);
	send(tid, data);
}

I got (dmd 2.068)
/usr/include/dmd/phobos/std/variant.d(633): Error: new can only 
create structs, dynamic arrays or class objects, not string[4]'s
[...]

with int[4] it compiles and runs. int[][4] fails. Is this a bug?

Simple workaround: send a slice.
Sep 01 2015
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 09/01/2015 09:47 AM, anonymous wrote:> Hello,
 I tried to send a string[4] with std.concurrency:

 import std.concurrency;
 import std.stdio;
 void fun() {
      receive((string[4] data) { writeln(data);});
 }

 void main() {
      string[4] data;
      auto tid = spawn(&fun);
      send(tid, data);
 }

 I got (dmd 2.068)
 /usr/include/dmd/phobos/std/variant.d(633): Error: new can only create
 structs, dynamic arrays or class objects, not string[4]'s
 [...]

 with int[4] it compiles and runs. int[][4] fails. Is this a bug?
I think so.
 Simple workaround: send a slice.
Another one: Wrap the array in a struct: struct Data { string[4] s; } Ali
Sep 01 2015
parent "anonymous" <a b.cd> writes:
On Wednesday, 2 September 2015 at 06:04:40 UTC, Ali Çehreli wrote:
 with int[4] it compiles and runs. int[][4] fails. Is this a
bug? I think so.
https://issues.dlang.org/show_bug.cgi?id=15004 may related to https://issues.dlang.org/show_bug.cgi?id=10740
Sep 02 2015