Exquisite code samples

renoX renozyx at gmail.com
Tue Jul 10 04:57:10 PDT 2012


On Monday, 9 July 2012 at 11:40:37 UTC, Gor Gyolchanyan wrote:
[cut]
> You're right. This is a bit advanced code sample, which uses 
> templates, template constraints, contract programming among 
> syntax advantages of D.

Hum it shows the power of D sure, but IMHO it also shows its 
syntax deficiencies..

For me this "real[d] bezier(size_t d, Number)(Number[d][] p, 
Number t)
    if(d > 1 && isFloatingPoint!Number)" is difficult to read, and 
a better syntax would be for example:
real[d] bezier!(size_t d && d > 1, Number && 
isFloatingPoint!Number)(Number[d][] p, Number t)
or:
real[d] bezier!(size_t d, Number; d > 1 && 
isFloatingPoint!Number)(Number[d][] p, Number t)

The template parameter would be indicated in a !() (as in a 
call), and the template constraints inside the template parameter

renoX


More information about the Digitalmars-d mailing list