Questions tagged [control-structures]
A control structure is a statement that changes the control flow in a program, based on the evaluation of one or more conditions. Common examples include the 'if-then-else' statement, the 'case-switch' statement, 'for' loops, and 'while' loops.
41 questions
-2 votes
4 answers
274 views
Block structured iteration and recursion
Programming languages traditionally have blocks that specifically cater to controlling iteration. There is the simple while-loop: while (i < 3) {...}; Then there is the more complicated for-loop: ...
0 votes
0 answers
89 views
Do mainstream definitions of basic blocks and extended basic blocks say anything about SKIP instructions?
Not many architectures have skip instructions today. They are (usually) conditional instructions that skip the following instruction. A few architectures having these: PIC14, with its btfss and btfsc ...
1 vote
3 answers
270 views
Is there an elegant way to structure consecutive short-circuited assignments?
The following code works and is clear, but it's also verbose. I suspect that there's a way to make it more terse, so that it could be skimmed quickly and it'd be more obvious what's happening. // The ...
2 votes
4 answers
253 views
is it worth rearrange if else structures to shorter form [duplicate]
In our project there are deep and lengthy if-else structures which can be significantly shortened by a simple rearrangement. To me the shorter version would be easier to understand also. As an ...
0 votes
3 answers
579 views
How to Simulate Control-Flow without using Control-Flow Primitives
Basically, I want to know how to simulate while and if if I'm handling the control flow myself through an array of instructions. The while loop can be simulated by if, as seen with assembly branching ...
4 votes
4 answers
170 views
Is there a pattern for dealing with one consistent case that's different from all others?
Been given an awkward design challenge, and I'm not sure how best to handle it. The scenario is this: in the system there's a concept of "Client". Each client has various bits of supporting metadata ...
2 votes
2 answers
103 views
Question about a maintainable approach on how to handle changes in the UI inside the source code
Inside our UI there's an option to select something from a dropdown. Depending on what you choose inside that menu the rest of the fields inside the UI change accordingly. At the moment we handle it ...
5 votes
6 answers
5k views
Flow control in Go without a for loop
I've been set a challenge that I'm trying to get my head around, but am struggling with the best (or 'correct') way to implement it. The challenge is to create a simple console app written in Go that ...