Implementing Half Floats in D

Timon Gehr timon.gehr at gmx.ch
Tue Jan 29 03:26:00 PST 2013


On 01/29/2013 11:40 AM, TommiT wrote:
> On Tuesday, 29 January 2013 at 08:48:24 UTC, Simen Kjaeraas wrote:
>> Except that's not a literal. 1.3.hf would be a function call, while
>> hf!1.3f
>> is a template instantiation.
>
> Can't help but point out, that some time ago, I made a suggestion to add
> a new function attribute to the language that would mean "evaluate any
> call to this function at compile time whenever it's possible". That
> would enable literals like:
>
> 1.3.hf
> and
> ComplexToConstruct(2.5, 7.5)
>
> Given:
> @property HalfFloat hf(float v) @aggressive_ctfe;
> and...
> struct ComplexToConstruct
> {
>      this(float x, float y) @aggressive_ctfe;
> }

I'd call it @constfold.


More information about the Digitalmars-d mailing list