How to convert C to D using compiler?

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Dec 10 18:43:32 UTC 2021


On Fri, Dec 10, 2021 at 05:49:44PM +0000, Guillaume Piolat via Digitalmars-d wrote:
[...]
> - as a heavy complex number users: you don't really write _that_ much
> literals often at all. 80% of these complex literals are zero and one (for
> which aliases would be maybe nice in std.complex btw)
> 
> - Complex literals always seemed a little un-D to me:
>       Complex!double(-2.1039 , 2.6575)

Hmm, technically you *could* do something like:

	enum i = Complex!double(0.0, 1.0);

which then lets you write:

	-2.1039 + 2.2.6575*i

of course, this then depends on the optimizer to optimize away the
redundant operation. But it would be more-or-less almost as readable as
built-in complex literals.


T

-- 
Жил-был король когда-то, при нём блоха жила.


More information about the Digitalmars-d mailing list