Can someone explain to me the design choices for this function definition?

Lodovico Giaretta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 22 14:41:38 PDT 2016


On Thursday, 22 September 2016 at 20:35:13 UTC, e-y-e wrote:
> [...]

Disclaimer: my answers are just early guesses.

> 1. Why is openRight a runtime flag? Is there really a use case 
> for this?

Runtime evaluation is more flexible. The reason to have 
compile-time evaluation is to allowed aggressive specialization, 
highly tuned codegen and different attribute inference. If that 
flag is going to add a single very cheap branch (compared to the 
total cost), then it may not be worth to have it as a 
compile-time argument, as this would increase the number of 
instantiations and slightly reduce the flexibility.

But there is a second possible explanation, see below.

> 2. Why is openRight not a Flag type?

It may be that until is quite old, predating the extensive usage 
of Flag, and maybe also the extensive use of compile-time flags.


More information about the Digitalmars-d-learn mailing list