Backend nearly entirely converted to D

Walter Bright newshound2 at digitalmars.com
Thu Nov 8 22:42:26 UTC 2018


On 11/8/2018 9:23 AM, welkam wrote:
> And where can i read about naming convention? My guess its not documented 
> anywhere and would not be in foreseeable future or ever. Also are you sure you 
> are not talking about two letter variables like
> sc for scope
> fd for function declaration
> td for template declaration

That is a naming convention. No, it's not documented. There's also `e` for 
Expression. `i` for loop index. Etc.


> What I want 
> to do is change variables like m. Try guessing what it is used for.

I don't need to guess. I look at its declaration a few lines up.


> What I dont understand is that you are against changing variable names that 
> would improve code understandability

This is where we diverge:

     Expression expression = new IntegerExp(loc, 1);
     expression = expression.expressionSemantic(sc);
     expression = resolveProperties(sc, expression);

is just exhausting compared with:

     Expression e = new IntegerExp(loc, 1);
     e = e.expressionSemantic(sc);
     e = resolveProperties(sc, e);


> but you are not against changing for loops 
> to foreach that add almost nothing to code readability and only look better.

Looking better is improving readability.

     foreach (m; modules)
     {
          ...
     }

is much more readable than:

     for (size_t i = 0; i < modules.dim; ++i)
     {
          Module m = modules[i];
          ...
     }

and much less prone to typo bugs. The for loop also is dependent on abstraction 
leak of modules[] being an array, whereas foreach only requires that the 
abstraction be traverse-able.


> What you dont know about me is that I worked as code reviewer/tester/merger at 
> PHP shop and know full well why you want pull requests the way you want. I also 
> know how much less easier it is to review simple changes like foreach loop 
> changes and simple variable renaming

It's great that you have valuable experience with this. Renaming variables, 
however, is not what I'm looking for. What I am looking for is using D to fix 
leaky abstractions, using const and pure, minimizing use of global mutable 
state, reducing the amount of code one must learn to make useful changes, 
reducing code duplication, minimizing the lifetime of variables, improving 
performance, etc.

For some more thoughts on this, check out my recent presentation on it:

http://nwcpp.org/october-2018.html


More information about the Digitalmars-d-announce mailing list