Exquisite code samples

Don Clugston dac at nospam.com
Tue Jul 10 02:24:41 PDT 2012


On 10/07/12 09:49, renoX wrote:
> 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)
>
> 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

Well it used to work vaguely in that way, but it gets very ugly once you 
leave the simplest cases.  Even that one you've listed is hard for me to 
read.
And the idea that constraints apply to individual parameters is wrong. 
If you have a constraint that depends on two template parameters, where 
do you put it?

int bezier (int A, int B)(int t) if ( A + B == 10 )






More information about the Digitalmars-d mailing list