dmd: if still there
Chris via Digitalmars-d
digitalmars-d at puremagic.com
Fri Sep 19 08:40:02 PDT 2014
On Friday, 19 September 2014 at 15:30:25 UTC, Daniel Murphy wrote:
> "Chris" wrote in message
> news:kcsnboocxeykhknjljfl at forum.dlang.org...
>
>> Out of curiosity. dmd still produces the if statement,
>> although it ain't gonna happen. Same is true of "DoIt.yes". I
>> know, it's an unlikely and marginal example.
>
> No it doesn't, here's main:
>
>> _Dmain:
>> push RBP
>> mov RBP,RSP
>> mov EDI,1
>> call _D7dump_if4doitFE7dump_if4DoItZv at PC32
>> xor EAX,EAX
>> pop RBP
>> ret
>> 0f1f
>> add [RAX],R8B
>> .text._Dmain ends
>
> See, no branches or comparisons.
All right, that escaped me. I'm not exactly asm-literate. Mea
maxima culpa! But good to know that you can rely on the compiler.
It's not that unusual actually. Often I have things like that in
my programs. I make the program flexible for extensions in the
future but until that happens it lives happily with something
like DoIt.no (usually in the signature flag = DoIt.no), i.e.
DoIt.yes is never used throughout the program. The if statement
should be kept alive in a library though, cos there's no way you
can foresee what users gonna do.
More information about the Digitalmars-d
mailing list