Is this a good way of setting up a timer?

Jonathan M Davis jmdavisProg at gmx.com
Sat Jun 4 22:31:03 PDT 2011


On 2011-06-04 11:14, Andrej Mitrovic wrote:
> Hey, so is there a reason I'm not allowed to use immutable here:
> 
> immutable finalTime = Clock.currTime + dur!"seconds"(5);
> 
> Error: cannot implicitly convert expression
> (currTime(cast(immutable(TimeZone))opCall()).opBinary(dur(5L))) of
> type SysTime to immutable(SysTime)

Because SysTime does not currently work with immutable. There are multiple 
compiler bugs which prevent it (including the fact that you can't use postblit 
with non-mutable objects). It _should_ work, but it doesn't. Once the compiler 
does a better job dealing with const and immutable (which I believe is on the 
todo list after fixing destruction for temporaries), then it should work, but 
for now, it doesn't.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list