Click here to Skip to main content
15,923,281 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: How do you decide which tyres you buy? Pin
Rob Philpott27-Sep-16 3:13
Rob Philpott27-Sep-16 3:13 
GeneralRe: How do you decide which tyres you buy? Pin
Johnny J.27-Sep-16 6:01
professionalJohnny J.27-Sep-16 6:01 
GeneralRe: How do you decide which tyres you buy? Pin
CDP180227-Sep-16 7:03
CDP180227-Sep-16 7:03 
GeneralAnother C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 0:35
kalberts27-Sep-16 0:35 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
dan!sh 27-Sep-16 0:47
professional dan!sh 27-Sep-16 0:47 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 0:56
kalberts27-Sep-16 0:56 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
OriginalGriff27-Sep-16 1:24
mveOriginalGriff27-Sep-16 1:24 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 3:01
kalberts27-Sep-16 3:01 
That 'onbreak' handles the 'exituntil' part.
It does not handle the 'exitfor' part - the code which is to be executed if you come to the end of the loop.

Besides, the way you define it: The block which contains the iterated code, the top {} pair, is closed and dead when you come to the onbreak {} part. So whichever variables were used in the loop - such as those causing the break condition, are inaccessible to the onbreak {}. I certainly hope that you are not going to suggest that local variables within the for {} block shall be accessible to the onbreak {} block!

Putting the loop code in a separate method helps nothing to handle alternate exit paths without having to set boolean flags. If you meant to include the alternate exit handlers in the method, what is the point of the method? If not: How would you indicate the required exit handling upon return to the caller of that method? How would the exit handlers be able to access the values causing that specific exit action, values local to the loop (function)?

You have another parsing problem in your proposal: The for loop is syntactically completed at the closing }. What follows it, could be any statement. You introduce an onbreak statement, not an onbreak clause of the for statement. The semantics of the for loop is modified by an adjacent statement (i.e. the onbreak) - that is sort of messy.

Obviously, I would like to have the exit clauses available in both for loops, foreach looops etc - the language providing exit clauses has a generalized 'for' control construct that covers both 'for' and 'foreach'). It also allows several exit tests (like the 'until') for while loops, similar to several 'if (cond) break;' - but since the main point is to provide different termination handling under different conditions, the mechanism would be most useful if you could provide arbirarily many 'exituntil' type clauses. I ceratainly would welcome that!

When I first was offered these alternate exit paths, it took me a while to see its real usefulness. But once you have learned to use it, and then move over to a language without it, you all the time tell yourself 'This would just have been so much more elegant if alternate exits were provided!'.
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
PeejayAdams27-Sep-16 1:42
PeejayAdams27-Sep-16 1:42 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
OriginalGriff27-Sep-16 1:53
mveOriginalGriff27-Sep-16 1:53 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
PeejayAdams27-Sep-16 2:28
PeejayAdams27-Sep-16 2:28 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 3:28
kalberts27-Sep-16 3:28 
JokeRe: Another C# syntax to wish for (or any C class language) Pin
Daniel Pfeffer27-Sep-16 3:58
professionalDaniel Pfeffer27-Sep-16 3:58 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 2:35
kalberts27-Sep-16 2:35 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
Richard Deeming27-Sep-16 3:15
mveRichard Deeming27-Sep-16 3:15 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 3:41
kalberts27-Sep-16 3:41 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
raddevus27-Sep-16 3:21
mvaraddevus27-Sep-16 3:21 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 3:58
kalberts27-Sep-16 3:58 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
jsc4227-Sep-16 3:23
professionaljsc4227-Sep-16 3:23 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 3:35
kalberts27-Sep-16 3:35 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
Marc Clifton27-Sep-16 4:20
mvaMarc Clifton27-Sep-16 4:20 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 4:31
kalberts27-Sep-16 4:31 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
Marc Clifton28-Sep-16 15:33
mvaMarc Clifton28-Sep-16 15:33 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
Ryan Peden27-Sep-16 5:25
professionalRyan Peden27-Sep-16 5:25 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
BillWoodruff27-Sep-16 17:05
professionalBillWoodruff27-Sep-16 17:05 

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.