Exquisite code samples
renoX
renozyx at gmail.com
Tue Jul 10 02:18:48 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 show the power of D sure, but IMHO it also show 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:
real[d] bezier!(size_t d && d > 1, Number &&
isFloatingPoint!Number)(Number[d][] p, Number t)
or maybe:
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: this way the template parameters are clearly indicated
and separated from the function parameter.
renoX
More information about the Digitalmars-d
mailing list