Backend nearly entirely converted to D

welkam wwwelkam at gmail.com
Thu Nov 8 17:50:20 UTC 2018


On Wednesday, 7 November 2018 at 22:08:36 UTC, H. S. Teoh wrote:
>
> I don't speak for the compiler devs, but IMO, one-letter 
> variables are OK if they are local, and cover a relatively 
> small scope.


By saying more descriptive I should have clarified that I meant 
to change them to 3-7 letter names. Small variable names are ok 
for small functions like the one in attrib.d called void 
importAll(Scope* sc). It has variable named sc and its clear 
where it is used.

Now for all of you who think that one letter variables are ok 
here is exercise. Go and open src/dmd/func.d with your favorite 
code editor. Find function FuncDeclaration resolveFuncCall(). Its 
around 170 LOC long. Now find all uses of variable Dsymbol s. Did 
you found them all? Are you sure? Ok now do the same for variable 
loc. See the difference?

> Java-style verbosity IMO makes code *harder* to read because 
> the verbosity gets > in your face, crowding out the more 
> interesting (and important) larger picture of code structure.

What editor do you use?
Here is the worst example to prove my point but its still 
sufficient. All editors worth your time highlights the same text 
when selected and here is example of one letter variable.
https://imgur.com/a/jjxCdmh
and tree letter variable
https://imgur.com/a/xOqbkmn

where is all that crowding and loss of large picture you speak 
of? Its the opposite. Code structure is more clear with longer 
variable names than one letter.

> As Walter said in his recent talk, the length of variable names 
> (or identifiers in general, really) should roughly correspond 
> to their scope

At best this is argument form authority. You said how thing 
should be not why. For argument sake imagine situation where you 
need to expand function. By your proposed rules you should rename 
local variables to longer names. Thats ridiculous. Yes I watched 
that presentation and fully disagree with Walter and know for 
sure he doesnt have sound argument to support his position.




More information about the Digitalmars-d-announce mailing list