digitalmars.D.learn - Comparison of TickDuration and StopWatch.peek
- Matej Nanut (28/28) Feb 28 2012 Hello everyone,
Hello everyone, I have the following code snippet: import core.time: TickDuration; import std.datetime: StopWatch, AutoStart; void main() { auto wait =3D TickDuration.from!`msecs`(1000); auto timer =3D StopWatch(AutoStart.yes); while (timer.peek < wait) // Okay. { } while (wait >=3D timer.peek) // Compile error. { } } I would like to know why the second =E2=80=98while=E2=80=99 doesn't compile= . The error is: comparison.d(13): Error: function core.time.TickDuration.opCmp (ref const(TickDuration) rhs) const is not callable using argument types (TickDuration) comparison.d(13): Error: timer.peek() is not an lvalue which I don't really understand. There shouldn't be a difference in =E2=80=98<=E2=80=99 and =E2=80=98>=3D=E2=80=99 apart from their result, or = should there be? =3D/ Same thing happens for =E2=80=98>=E2=80=99. Also, I can use =E2=80=98peek=E2=80=99 without parenthesis even though it i= sn't marked as property on dlang.org, am I missing something? I probably read the spec incorrectly somewhere for this one. Thanks, Matej
Feb 28 2012