I can't understand why. Does it make sense to you? The type has already been declared, so re-typing the type is a waste of space and inviting typos etc. Auto makes it easier to comprehend. You don't have to go through all the mental hoops all over again.
Coding. style
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 176
- Joined: Wed Mar 09, 2022 3:15 am
- Location: Oz
Re: Coding. style
-
- Posts: 176
- Joined: Wed Mar 09, 2022 3:15 am
- Location: Oz
Re: Coding. style
Easy. Just change the name of the duplicate variable to some arbitary name.
The latter (leading _) I understand is all about not polluting the global space (plenty of that here). Not hard to fix, but might need some concensus on naming convention. Any inputs?
-
- Posts: 176
- Joined: Wed Mar 09, 2022 3:15 am
- Location: Oz
Re: Coding. style
I somewhat disagree. Many are just simple replace. In an IDE trivial. (With enormous respect) surely way below the pay grade of a founder.
-
- Posts: 176
- Joined: Wed Mar 09, 2022 3:15 am
- Location: Oz
-
- Posts: 176
- Joined: Wed Mar 09, 2022 3:15 am
- Location: Oz
Re: Coding. style
Yes, looking at the code there have been some updates, but (and I'm almost loath to say this for fear of being flamed) you only have to look at the code to know much of it is legacy style. As Werner said, much of it was written in C++98 and is up to 20 years old. 5000 line files? Tangled responsibilites? Polluted global space. These things were the norm when written, but the world has moved on a bit ... (please don't flame).
Re: Coding. style
Really? IMO, using auto for iterators is one of the best possibilities to use it because you don't have to repeat all the template parameters of the container.
+1FreddyFreddy wrote: ↑Wed Apr 20, 2022 7:23 am I can't understand why. Does it make sense to you? The type has already been declared, so re-typing the type is a waste of space and inviting typos etc. Auto makes it easier to comprehend. You don't have to go through all the mental hoops all over again.
Concrete example?FreddyFreddy wrote: ↑Wed Apr 20, 2022 7:29 am The latter (leading _) I understand is all about not polluting the global space (plenty of that here). Not hard to fix, but might need some concensus on naming convention. Any inputs?
Re: Coding. style
I do recall I was asked to revert. In that case though there weren't too many template parameters to be provided, and I was replacing the explicitly stated type with auto. I believe the precedent set was "you can use auto in new loops, but if a type is already provided, no need to change it". It might also not have been for an iterator, in which case the argument weakens a little bit.
Hi Uwe. Mind hopping in with your inputs? Do you recall what the PR was where we talked about it?uwestoehr wrote: Hi
My latest (or last) project: B-spline Construction Project.
Re: Coding. style
Oh I'm far from a founder (not even getting into the paygrade part ).FreddyFreddy wrote: ↑Wed Apr 20, 2022 7:35 am Many are just simple replace. In an IDE trivial. (With enormous respect) surely way below the pay grade of a founder.
As for the ease of replacing, that may be the case but I'd still be cautious in my steps. Regardless, I see you're set on your plan so not gonna stop you.
My latest (or last) project: B-spline Construction Project.
Re: Coding. style
No inputs as such. The convention changes module to module, and only some modules have a set guideline (which is not even strongly imposed).FreddyFreddy wrote: ↑Wed Apr 20, 2022 7:29 am The latter (leading _) I understand is all about not polluting the global space (plenty of that here). Not hard to fix, but might need some concensus on naming convention. Any inputs?
My latest (or last) project: B-spline Construction Project.
Re: Coding. style
https://github.com/FreeCAD/FreeCAD/pull ... r757918354
This is the code block:
Code: Select all
// shells are already closed - add them directly
for (TopoDS_Shape& s : shells) {
mkSolid.Add(TopoDS::Shell(s));
}