3 ms·
EDIT: i assume here you mean explicitly typing out type names, like in Pascal's "var name: type" or C's "type name" and not something else. I am not a fan of t
by badsectoracula 5y ago
EDIT: i assume here you mean explicitly typing out type names, like in Pascal's "var name: type" or C's "type name" and not something else.
I am not a fan of this because the type attributes also act as documentation for that the variables, parameters, etc are supposed to be and that clearly typed out text is much easier and faster to read than some IDE's tooltip at a mouse hover or whatever (assuming you even have that in the context you see the code - even if your primary IDE supports this, you may still need to read the code outside of the IDE and sometimes outside of the surrounding code like, e.g. reading a diff).
And yes, for that reason C++'s "auto" is one of my least favorite additions to the language. Even when i have to use the language, i avoid using "auto".
(if anything sometimes feel that readability benefits when having to be explicit not only about types but also the parameter names in function calls ala Smalltalk... e.g. in Pascal i sometimes wonder what that "True" or "1" really means in a call. In recent versions of Free Pascal that have added scoped enum support - like class enums in C++ - i try to use those instead of booleans as they document the API even when it is used but this is only a small case)
- pjmlp 5y agoThat was actually a kind of jab how D nowadays has a jungggle of attributes, and the workaround taken by most on the community. https://dlang.org/spec/attribute.html https://dlang.org/spec/attribute.html Most likely you are aware of this already, but even Delphi has type inference via inline variables. Personally I enjoy using type inference everywhere on my own code. At work, I take the rule of only using it when the type is clear, e.g. auto mySomething = new Something();
- badsectoracula 5y ago> That was actually a kind of jab how D nowadays has a jungggle of attributes, and the workaround taken by most on the community. Ah yeah, this is why i added that EDIT but you replied before i did :-P. I agree about that part, i remember D being a bit attribute trigger happy :-P but i guess the alternative would be to break backwards compatibility which is IMO worse. Though perhaps something similar to Free Pascal's "modeswitch" directive would help (FP devs use it to introduce new syntax without breaking backwards compatibility). > Delphi has type inference via inline variables I know it is there but i don't really like it myself for the reasons i mentioned above (also i prefer sticking all variables together even in C++, too much code is usually a sign i need to break the functions into subfunctions and Pascal allowing nested functions is a feature i use very often). It is also one of the very very few case where Free Pascal developers have explicitly decided to not implement something because they feel it doesn't fit the language :-P.