Question about publishing a useful function I have written
Cecil Ward
cecil at cecilward.com
Wed Jul 15 09:31:27 UTC 2020
On Tuesday, 14 July 2020 at 23:10:28 UTC, Max Haughton wrote:
> On Tuesday, 14 July 2020 at 21:58:49 UTC, Cecil Ward wrote:
>> I have written something which may or may not be novel and I’m
>> wondering about how to distribute it to as many users as
>> possible, hoping others will find it useful. What’s the best
>> way to publish a D routine ?
>>
>> [...]
>
> GitHub is the best place to publish code. Does GDC actually use
> the optimization? I tried something like that before but I
> couldn't seem to get it to work properly.
On Tuesday, 14
]
I just tried an experiment. It seems that in release mode
assert()s are realised as absolutely nothing at all, and so the
_conditions_ in the asserts are not declared. So later generated
code does not have the benefit of knowledge of asserted truth
conditions in release mode. So in release mode, without these
truth conditions being established, the code generated (apart
from the asserts’ code) can be _worse than in debug mode_, which
seems bizarre, but it’s true.
for example
assert( x < 100 );
…
if ( x==200 ) // <— evaluates to false _at compile time_
{
// no code generated for this block in debug mode,
// but is generated in release mode
}
…
if ( x < 100 ) // <— no code generated for if-test as cond ==
true at compile-time
More information about the Digitalmars-d-learn
mailing list