Some questions on latest work

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 28 15:40:36 PDT 2016


On 28.04.2016 05:55, Joakim wrote:
> On Wednesday, 27 April 2016 at 18:38:17 UTC, Max Samukha wrote:
>> On Tuesday, 26 April 2016 at 18:16:42 UTC, Joakim wrote:
>>
>>>
>>> He gave very specific criticism, along with a code sample, then made
>>> a prediction, followed by suggesting another competing language that
>>> might do better.  None of that is the usual content-free fanboy
>>> "bashing."  There is nothing wrong with occasional criticism of the
>>> competition, as long as we don't overdo it, either in frequency or by
>>> exaggerating.
>>
>> No, judging a language by the appearance of its syntax *is* fanboy
>> bashing. BTW, some interesting points about Swift made by a Rust
>> designer http://graydon2.dreamwidth.org/5785.html.
>
> Syntax matters.  Both for the ease of programmers reading it and, as
> we've seen with C++, the speed of the compiler.
>
> I look at that code sample and I don't want to read code like that.  I
> have the same feeling when I see template-heavy C++ code.  It is one of
> the primary reasons I use D, because it reads very easily to me.
>
> Is it just because I'm used to C-style code?  Is it purely aesthetic?  I
> don't know, but there is a difference.  Walter has talked about an
> aesthetic quality to D that he tries to optimize, and whatever it is, it
> comes through to me.
> ...

This is some D code I wrote:

template CreateBinderForDependent(string name, string fun=lowerf(name)){
     mixin(mixin(X!q{
         template @(name)(string s, bool propErr = true) 
if(s.split(",")[0].split(";").length==2){
             enum ss = s.split(";");
             enum var = ss[0];
             enum spl = var.split(" ");
             enum varn = strip(spl.length==1?var:spl[$-1]);
             enum sss = ss[1].split(",");
             enum e1 = sss[0];
             enum er = sss[1..$].join(" , ");
             enum @(name)=`
                 auto _@(name)_`~varn~`=`~e1~`.@(fun)(`~er~`);

                 if(auto d=_@(name)_`~varn~`.dependee){
                     static if(is(typeof(return) A: Dependent!T,T)) 
return d.dependent!T;
                     else 
mixin(`~(propErr?q{SemProp}:q{PropRetry})~`!q{sc=d.scope_;d.node});
                 }
 
`~(propErr?`assert(!_@(name)_`~varn~`.dependee,text("illegal dependee 
",_@(name)_`~varn~`.dependee.node," 
",_@(name)_`~varn~`.dependee.node.sstate));`:``)~`
                 static 
if(!is(typeof(_@(name)_`~varn~`)==Dependent!void))`~var~`=_@(name)_`~varn~`.value;
             `;
         }

     }));
}

Ugly code can be written in any language.


More information about the Digitalmars-d mailing list