Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-03-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 01, 2017 17:02:37 Dukc via Digitalmars-d-learn wrote: > On Wednesday, 1 March 2017 at 16:43:41 UTC, Jonathan M Davis > > wrote: > > Assert is for program invariants. If the condition is true, > > your program is outright broken. > > Error: He meant that if the condition is

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-03-01 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 1 March 2017 at 09:19:53 UTC, Christian Köstlin wrote: On 01/03/2017 00:09, Joseph Rushton Wakeling wrote: if (!__ctfe) assert(false); ... might be the best option. That shouldn't be compiled out even in -release builds. thats a nice idea! is this happening because of

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-03-01 Thread Dukc via Digitalmars-d-learn
On Wednesday, 1 March 2017 at 16:43:41 UTC, Jonathan M Davis wrote: Assert is for program invariants. If the condition is true, your program is outright broken. Error: He meant that if the condition is FALSE, the program is faulty.

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-03-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, February 28, 2017 09:16:47 sarn via Digitalmars-d-learn wrote: > On Tuesday, 28 February 2017 at 07:41:36 UTC, Christian Köstlin > > wrote: > > As I understand the only difference between assert and enforce > > is, that > > assert is not compiled into releases? > > > > Thanks! > >

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-03-01 Thread Christian Köstlin via Digitalmars-d-learn
On 01/03/2017 00:09, Joseph Rushton Wakeling wrote: > On Tuesday, 28 February 2017 at 00:22:28 UTC, sarn wrote: >>> If you ever have doubts, you can always use something like this to >>> check: >>> >>> assert (__ctfe); >> >> Sorry, "enforce" would more appropriate if you're really checking. > >

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-28 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 00:22:28 UTC, sarn wrote: If you ever have doubts, you can always use something like this to check: assert (__ctfe); Sorry, "enforce" would more appropriate if you're really checking. if (!__ctfe) assert(false); ... might be the best option. That

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-28 Thread sarn via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 07:41:36 UTC, Christian Köstlin wrote: As I understand the only difference between assert and enforce is, that assert is not compiled into releases? Thanks! Christian Pretty much so. The intention is that assert means something that's supposed to be true

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-27 Thread Christian Köstlin via Digitalmars-d-learn
On 28/02/2017 01:20, sarn wrote: > On Monday, 27 February 2017 at 19:26:06 UTC, Christian Köstlin wrote: >> How can I make sure, that the calculations are done at compile time? > > If you ever have doubts, you can always use something like this to check: > > assert (__ctfe); Thanks a lot,

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-27 Thread sarn via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 00:20:05 UTC, sarn wrote: On Monday, 27 February 2017 at 19:26:06 UTC, Christian Köstlin wrote: How can I make sure, that the calculations are done at compile time? If you ever have doubts, you can always use something like this to check: assert (__ctfe);

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-27 Thread sarn via Digitalmars-d-learn
On Monday, 27 February 2017 at 19:26:06 UTC, Christian Köstlin wrote: How can I make sure, that the calculations are done at compile time? If you ever have doubts, you can always use something like this to check: assert (__ctfe);

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-27 Thread Dukc via Digitalmars-d-learn
On Monday, 27 February 2017 at 19:26:06 UTC, Christian Köstlin wrote: Is it enough to put up static immutable modifiers? How can I make sure, that the calculations are done at compile time? ... static immutable time = Unit("time", [Unit.Scale("ms", 1), ... An initialization of a static

How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-27 Thread Christian Köstlin via Digitalmars-d-learn
I have a small example, that can be used to express 3601000ms as 1h 1s (a much more advanced version has already been done by https://github.com/nordlow/units-d). I would like to enforce that the precomputation (multiplying and inverting the list of scale's) is done at compile time. Is it enough