www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - TickDuration = Divide by Zero

reply Chris Williams <yoreanon-chrisw yahoo.co.jp> writes:
I have the following code:

import std.datetime;

const TickDuration a;
static this() {
	a = TickDuration.from!"msecs"(15_000);
}

int main() {
	writefln("Hello world!"); // is never printed

	return 0;
}

When I run it, I get the following output:

object.Error: Integer Divide by Zero

I presume that TickDuration is trying to access something that it
doesn't have access to yet, during startup. Is there another way to
make my constant a constant?
Oct 03 2011
parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Mon, 03 Oct 2011 19:09:31 +0300, Chris Williams  
<yoreanon-chrisw yahoo.co.jp> wrote:

 I presume that TickDuration is trying to access something that it
 doesn't have access to yet, during startup.
http://d.puremagic.com/issues/show_bug.cgi?id=6631
 Is there another way to make my constant a constant?
How about using something with a resolution known at compilation time (e.g. a Duration)? -- Best regards, Vladimir mailto:vladimir thecybershadow.net
Oct 03 2011