On 01/17/2012 05:02 PM, Don Clugston wrote:
On 15/01/12 20:35, Timon Gehr wrote:
On 01/14/2012 07:13 PM, Vladimir Matveev wrote:
Hi,
Is there a reason why I cannot compile the following code:
module test;
struct Test {
int delegate(int) f;
}
Test s = Test((int x) { return x + 1; });
void m
On 15/01/12 20:35, Timon Gehr wrote:
On 01/14/2012 07:13 PM, Vladimir Matveev wrote:
Hi,
Is there a reason why I cannot compile the following code:
module test;
struct Test {
int delegate(int) f;
}
Test s = Test((int x) { return x + 1; });
void main(string[] args) {
return;
}
dmd 2.057 say
On 01/14/2012 07:13 PM, Vladimir Matveev wrote:
Hi,
Is there a reason why I cannot compile the following code:
module test;
struct Test {
int delegate(int) f;
}
Test s = Test((int x) { return x + 1; });
void main(string[] args) {
return;
}
dmd 2.057 says:
test.d(7): Error: non-co
On Sun, Jan 15, 2012 at 02:21:04PM +, Vladimir Matveev wrote:
> Thanks, that was very helpful. Module initializer works like a charm.
> Shame I didn't find it in the documentation. Thanks again.
[...]
It's discussed briefly in Andrei's book (section 11.3, p.356).
T
--
If it's green, it's b
Thanks, that was very helpful. Module initializer works like a charm. Shame I
didn't find it in the documentation. Thanks again.
Best regards,
Vladimir.
I guess these are CTFE (compile-time function evaluation) issues,
someone else might know more. A workaround is to use a module
constructor which will run before main():
struct Test {
int delegate(int) f;
}
Test s;
static this() {
s = Test((int x) { return x + 1; });
}
Note that 's' is t