Click here to Skip to main content
15,892,809 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
trønderen20-Dec-21 6:25
trønderen20-Dec-21 6:25 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
David O'Neil20-Dec-21 6:48
professionalDavid O'Neil20-Dec-21 6:48 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Rich Shealer21-Dec-21 2:46
Rich Shealer21-Dec-21 2:46 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
David O'Neil21-Dec-21 12:40
professionalDavid O'Neil21-Dec-21 12:40 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
James Lonero23-Dec-21 7:15
James Lonero23-Dec-21 7:15 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Marc Clifton20-Dec-21 8:46
mvaMarc Clifton20-Dec-21 8:46 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Slacker00720-Dec-21 8:54
professionalSlacker00720-Dec-21 8:54 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
trønderen20-Dec-21 12:22
trønderen20-Dec-21 12:22 
Slacker007 wrote:
Marc Clifton wrote:there should always be a single point of return
I can accept your principle, but honestly: I do not really see the advantage of coding 'goto returnfromfunction' rather than 'return' (obviously, there is then a 'returnfromfunction' label at the end of the function). If you do not recognize the 'return', then why would you more easily recognize 'goto returnfromfunction'?

This is probably related to
Slacker007 wrote:
I also like to reduce nesting If statements. Some devs love 50,000 nested If statements. No thank you.
Way back in my student days, there was an article in one of the ACM publications, it may have been Communications, but more likely SIGPlan Notices, entitled "The rightward migration of source code", discussing the consequences of without question accepting such dogmas as 'single point of return'.

The consequences of 'single point of return' may depend strongly on which other coding 'rules' are enforced. I have frequently seen 'single exit point' together with 'break out of loops is forbidden'. So if you detect a fatal error at iteration 2 of a 100 iteration loop, you cannot terminate, but must set an error flag, tested in every one of the subsequent 98 iterations in a 'if (!errorterminate) ...

If 'break' is forbidden, so you are not allowed to write a 'do {} while (false);' with, say, every parameter check either continues, or breaks out, then you cold cause the exit, say, on an invalid parameter, by creating such a one-iteration loop, with an exception handler. Sometimes, managers who strongly object to break statements willingly accept raise statements.

Of course this makes next to zero sense. But lots of programmers who dislike explicit statements seem to fully accept exception handling to do the same thing. One obvious magic - the break or return - is forbidden, while something obscure, handled independently from each side, is fully accepted. I do not see why.

Like Slacker007, I fight rightward migration. Allowing multiple return points is part of the fight.
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Peter Adam20-Dec-21 20:30
professionalPeter Adam20-Dec-21 20:30 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
James Lonero23-Dec-21 7:39
James Lonero23-Dec-21 7:39 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
James Lonero23-Dec-21 7:12
James Lonero23-Dec-21 7:12 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Gary R. Wheeler20-Dec-21 7:14
Gary R. Wheeler20-Dec-21 7:14 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Slacker00720-Dec-21 8:59
professionalSlacker00720-Dec-21 8:59 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Leo5620-Dec-21 23:57
Leo5620-Dec-21 23:57 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
dan!sh 20-Dec-21 22:11
professional dan!sh 20-Dec-21 22:11 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
MadGerbil21-Dec-21 1:47
MadGerbil21-Dec-21 1:47 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
rjmoses21-Dec-21 10:51
professionalrjmoses21-Dec-21 10:51 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
rjmoses21-Dec-21 10:54
professionalrjmoses21-Dec-21 10:54 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
englebart21-Dec-21 13:05
professionalenglebart21-Dec-21 13:05 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Ryan Peden21-Dec-21 17:48
professionalRyan Peden21-Dec-21 17:48 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Matt McGuire22-Dec-21 6:01
professionalMatt McGuire22-Dec-21 6:01 
GeneralRe: CCC 20-12-2021 - Solution Pin
pkfox20-Dec-21 2:11
professionalpkfox20-Dec-21 2:11 
GeneralRe: CCC 20-12-2021 - Solution Pin
OriginalGriff20-Dec-21 2:17
mveOriginalGriff20-Dec-21 2:17 
GeneralRe: CCC 20-12-2021 - Solution Pin
pkfox20-Dec-21 3:14
professionalpkfox20-Dec-21 3:14 
GeneralRe: CCC 20-12-2021 - Solution Pin
OriginalGriff20-Dec-21 3:30
mveOriginalGriff20-Dec-21 3:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.