Re: Duration at runtime

2016-02-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/18/16 11:36 PM, Zekereth wrote: On Friday, 19 February 2016 at 04:21:43 UTC, Zekereth wrote: On Friday, 19 February 2016 at 04:16:23 UTC, Adam D. Ruppe wrote: On Friday, 19 February 2016 at 04:08:02 UTC, Zekereth wrote: How is seconds able to be read at compile time but unitType cannot?

Re: Duration at runtime

2016-02-18 Thread Zekereth via Digitalmars-d-learn
On Friday, 19 February 2016 at 04:21:43 UTC, Zekereth wrote: On Friday, 19 February 2016 at 04:16:23 UTC, Adam D. Ruppe wrote: On Friday, 19 February 2016 at 04:08:02 UTC, Zekereth wrote: How is seconds able to be read at compile time but unitType cannot? "seconds" is a literal value that the

Re: Duration at runtime

2016-02-18 Thread Zekereth via Digitalmars-d-learn
On Friday, 19 February 2016 at 04:16:23 UTC, Adam D. Ruppe wrote: On Friday, 19 February 2016 at 04:08:02 UTC, Zekereth wrote: How is seconds able to be read at compile time but unitType cannot? "seconds" is a literal value that the compiler knows about. unitType is a variable that might chan

Re: Duration at runtime

2016-02-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 19 February 2016 at 04:08:02 UTC, Zekereth wrote: How is seconds able to be read at compile time but unitType cannot? "seconds" is a literal value that the compiler knows about. unitType is a variable that might change between its declaration and use (it doesn't here, but the compi

Duration at runtime

2016-02-18 Thread Zekereth via Digitalmars-d-learn
I'm confused by the following: import std.stdio; import std.datetime; void main() { string unitType = "seconds"; auto seconds = 1; // auto myDur = dur!(unitType)(seconds); // Error unitType can't be read at compile time. auto myDur = dur!("seconds")(seconds); // Compile