Talk:Control flow

From Wikipedia, the free encyclopedia

Control flow was a good article candidate, but did not meet the good article criteria at the time. Once the objections listed below are addressed, the article can be renominated. You may also seek a review of the decision if you feel there was a mistake.

Date of review: No date specified. Please edit template call function as follows: {{FailedGA|insert date in any format here}}

This article is within the scope of WikiProject Computer science.
B rated as B-Class on the assessment scale
High rated as High-importance on the assessment scale

From Murray Langton:

Nobody commented on my outline for a complete rewrite, so I have done the rewrite.

Contents

[edit] "Constructs to be avoided"

Wikipedia is not prescriptive; it can at best report what others prescribe. "You should not [otherwise] [do X]" is something Wikipedia must never, ever say. "Smith and Thompson and Jones all agree you shouldn't [do X]" and "nobody [does X] anymore [because]" are fine.

The part about goto was redundant with the section on goto, so I deleted it. The historical and arcane control flow structures were not discussed, so I merged them in their appropriate sections. I'm sad to say the link to Knuth's paper was broken and I couldn't find a substitute; hope you paid those ACM subscription fees. 82.92.119.11 21:26, 14 September 2005 (UTC)

[edit] Redirect from Elif

There is a redirect from the ELIF wikipedia entry, but although this is a subclass of the IF command, there is no reference to ELIF in this article

fixed --Krischik T 13:12, 24 February 2006 (UTC)

[edit] Control flow constructs are a special kind of statements

IMHO Statements are a larger group containing control flow constructs as special case. For example: Many programming languages have assignment-, declaration-, I/O- and assert-statements which are not control flow constructs. I improved the statement article a little bit and added some links to it.

[edit] Lanugage examples.

I think the modlue has to many language examples. We should realy concentrate on the actual contruct and how it works and leave programming language dependent part to pages describing that language - or even better Wikibooks.

As it is I think the page is not clear enough

--Krischik T 11:49, 17 February 2006 (UTC)

[edit] Loop with test in the middle

As Ada actualy got the Loop with test in the middle I wonder ot it actually is a Proposed control structure. --Krischik T 07:25, 23 February 2006 (UTC)

How does Ada cope when you want to exit from the middle of several nested loops (as per example of searching 2-D array)? Murray Langton 21:40, 23 February 2006 (UTC)
Sorry, query about wrong control structure. Murray Langton 21:42, 23 February 2006 (UTC)
You can name a look and then use exit Outer_Loop when Condition; --Krischik T 07:03, 24 February 2006 (UTC)

[edit] Exceptions vs continuations

In 6 Structured non-local control flow it says: "Exceptions, conditions, and continuations are three common sorts of non-local control constructs."

Are PL/1 conditions any different from exceptions? If so, the article should explain how; if not, the two sections should be combined.

-- Brock

Interesting point. The difference is a bit like if then goto vs. if then else One is structured the other is not but apart from that they do the same thing. BTW: Some Basic dialects and Rexx have that contruct as well. --Krischik T 13:08, 24 February 2006 (UTC)

[edit] GA failed

For these reasons:

  1. Lead fails to represent the article.
  2. The example that follow this, In many programming languages, a label is an identifier. should state which language it is from.
  3. For every piece of code the language should be mentioned beside it.
  4. For a fuller discussion on the drawbacks of goto, see Goto., should go in the front.
  5. Inline external links should be placed in a footnotes or references section at the bottom of the article.
  6. A number of authors have pointed out that using goto is often acceptable, like whom for example or where is this piece of info from?
  7. Subroutines can be made much more useful by providing them with parameters and what are the disadvantages of not providing params?
  8. In need of wikilinks for definition of words, e. g., tree-traversals, overhead, stack ...
  9. The program will end execution after the third line without continuing into the function. ... why?
  10. The fact that such minimalism is possible does not necessarily mean that it is desirable and who said that? ref please or make it more NPOV.
  11. after all, computers theoretically only need one machine instruction (subtract one number from another and branch if the result is negative), but practical computers have dozens or even hundreds of machine instructions., simplistic view maybe ref this part too. Is this really necessary in an encyclopedia.
  12. Languages whose final keyword is of the form: end + initial keyword (with or without space in the middle) tend to be easier to learn and read. says who?
  13. The Choice section should demonstrate statements universally without needing the Ada language. Thus turn every code into Ada-free code or wikilink to other wikipedia articles like: If should point to Conditional statement.
  14. The tables should conform to the Footnotes method for the comments added to them.
  15. The Anecdotal evidence section needs more introduction for non-experts. Lincher 02:29, 16 June 2006 (UTC)
(Changed User:Lincher's above list from bullets to numbered list to facilitate discussion - Dmeranda 18:17, 30 June 2006 (UTC))
For (1), I rewrote the lead section so it should meet WP guidelines -- Dmeranda 18:22, 30 June 2006 (UTC)


[edit] Early exit and infinite loops

Deep break/early exit is simulated in C and C++ not through exceptions but via goto's and labels. Also, infinite loops which are conditionless are simulated through labels and gotos as well; this avoids a conditional check if you really want an infinite loop.

รณ

[edit] Python for-else and while-else constructs

There was some confusion over when the else-clause of a Python for or while loop is executed. A simple test case shows this

for i in [42]:
    if i == 42:
        print 'Breaking out of for loop'
        break
else:
    print 'In else clause of for loop'

when run outputs only "Breaking out of for loop". Likewise changing "i == 42" to "i == 99" and re-running only outputs "In else clause of for loop". So the else clause is executed on if the loop is not exited early by a break statement. -- Dmeranda 16:37, 19 March 2007 (UTC)