Talk:Statement (computer science)

message: I was under the impression that Pascal was defined using lower-case letters for all the keywords.  Does anyone know different?  If no response within a week, I'll change things to lower-case. Murray Langton 09:35, 7 February 2006 (UTC)

message: There are a couple of sentences that say "most programming languages", but I don't know that's statistically a true characterization. In fact, I know there are many languages in which those descriptions of statements are false. Unless someone can provide references that support the use of the phrase "most languages", I think they should be replaced with "many" or even "typically". — Chris Page 21:15, 8 May 2007 (UTC)
replies: text: I guess until somebody actually does the counting we should go with something less emphatic (not that I might have any views one way or the other ;-). Derek farn 22:52, 8 May 2007 (UTC)

text: Perhaps a rephrase to "most imperative programming languages" would be appropriate, since this type of language is what the bulk of this article is concerned with. Murray Langton 15:02, 9 May 2007 (UTC)
replies: text: I would have said that all imperative programming languages have statements.  Isn't that one of the things that makes them imperative?  On the other hand how many non-imperative language shave statements?  I guess it comes down to what the designer of a language decided to call a statement.  Could I define a prolog like language and decide to call things that look like clauses statements?  Perhaps we need to revisit the definition of statement, I am beginning to think we might need a definition that does encompass a construct that appears in all executable languages. Derek farn 17:38, 9 May 2007 (UTC)
replies: text: It would make much more sense to call Prolog clauses "statements" but usually they aren't called that. In imperative languages, it should be "instructions", but historically they're called statements, so we're stuck with that, even if they aren't the same as logical statements at all. The equivalent of a logical statement in programming is a Boolean expression. --88.74.206.222 (talk) 01:23, 29 October 2016 (UTC)
thread_title:  "Most programming languages" 

message: Defining new statements is possible in Lisp. But you still have to use the list notation for your statements. Languages of the Lisp family have inherited that feature. There are also languages like Seed7 which allow the definition of new statements syntactically and semantically. But what is that: "Snobol4 allows new statements to be created during program execution." I can only speculate about what it means to create a new statement during program execution. Can it be that the new statements are created in the interpreter while it is interpreting the program. In that case the definition of the new statement must be part of the program. Possibly this is a reference to self modifying code. Can somebody give me more information. Zron 14:18, 31 October 2007 (UTC)
thread_title:  Create new statements during program execution? 

message: The following statement (no pun intended) mixes the terms "definition" and "declaration":
:Many languages (e.g. C) make a distinction between statements and definitions, with a statement only containing executable code and a definition declaring an identifier.
A variable definition is (or at least can be) distinct from a variable declaration.  In the case of 'C' the variable type is defined using the typedef (type definition) keyword, however an instance of that variable is declared for use in a program simply by using the newly defined type name.  —Preceding unsigned comment added by 82.2.62.83 (talk) 17:44, 8 October 2008 (UTC)
thread_title:  Use of "declaration" and "definition" 

message: I added two paragraphs to point out several things that are not mentioned in the article:
* Since statements are used frequently they dominate the appearance of a program.
* In imperative languages statements are usually characterized by special syntax and special semantics.
* The special syntax and semantics of statements is usually described outside the language (in reference / standard documents which use natural language and some form of syntax description which is not part of the language). That means that in the common case a programmer is not able to specify syntax or semantic of a statement (Examples of languages where the syntax or semantic or both can be specified should be added also).
Sorry to use the term vandalism but it is IMHO not OK to just remove some information. Georg Peter (talk) 14:37, 8 August 2010 (UTC)
replies: text: First of all, please do not characterize good-faith edits with sensible Edit Summaries ("Well meaning edit containing generalised points of view and incorrect claims (eg, most statements do not start with if/for/while") as 'vandalism'.  I agree with User:Derek farn's judgement here.  The second addition, in particular, which mentions that language definitions define the syntax and semantics of statements, is not specific to statements; it is equally true of expressions, declarations, and other language elements. --Macrakis (talk) 14:47, 8 August 2010 (UTC)
replies: text: Ok, I will assume good-faith. I overreacted because the nice Edit Summary was combined with a complete revert. This is IMHO not a strategy to encourage part time contributors of Wikipedia. BTW: My change did NOT intend to claim that "most statements start with if/for/while". So it can be that User:Derek farn started with a false premise. Of couse all language elements are defined somehow in the language definition. But there are things that do not need to be part of the (basic) language definition, such as classes and methods defined in libraries. Class libraries can usually be defined in the language itself (the class libraries of Java and C++ are written in Java and C++ respectively). I want to point out that in most programming languages statements, declarations and some other language elements cannot be defined in a library. Everybody assumes that this needs to be the case, but this is not true. There are languages (such as LISP or Seed7) which allow user defined statements. Consequently in such languages statements can be defined in the language itself. Therefore such statements may even not be mentioned in the language definition. This concept might not be reasonable or desirable, but it is possible. It IMHO improves the understanding of what a statement is, when such things are mentioned also. Georg Peter (talk) 15:47, 8 August 2010 (UTC)

text: OK, I see your point, and will edit the article to reflect it. PS I worked on extensible languages (EL/1) in the 80's.... --Macrakis (talk) 15:16, 8 August 2010 (UTC)
replies: text: Thank you (BTW: I wrote the paragraph above before I saw your response. Since it was so much work I do not have the heart to leave it out :-) ). Georg Peter (talk) 15:47, 8 August 2010 (UTC)
thread_title:  Statement syntax and the definition of statements in standard documents 

message: Why are they called statements? Who decided to call them that? Mathematically a statement is a Boolean expression. "Statements" in imperative languages are not statements in that sense, they are commands. They describe a state transition, not a condition that may be true or false.--92.214.175.181 (talk) 19:12, 21 December 2018 (UTC)
replies: text: Use of <statement> dates back many decades e.g. Flow-Matic (predecessor to Cobol) in 1955, Fortran 1 Manual in 1956, Algol 60 Report published in 1960.  I don't know where it came from. Murray Langton (talk) 23:48, 21 December 2018 (UTC)
thread_title:  Why the name? 

message: I didn't understand the example under the Expressions section. Why is print any different between the first and second lines? It doesn't seem to qualify as an expression under the given definition of always returning a result and not having side effects. 124.214.42.86 (talk) 01:46, 17 August 2020 (UTC)
thread_title:  Confusing example? 

message: I see no reason to mention that DO10I is an "implicitly declared" variable. Whether variables need to be declared or not (they don't in Fortran) is completely orthogonal to the syntactic ambiguity here. Yes, if Fortran required all variables to be declared, this ambiguity would be unlikely to happen, but I don't think that's relevant here. --Macrakis (talk) 17:28, 15 February 2021 (UTC)
replies: text: OK, I see your point. Murray Langton (talk) 17:45, 15 February 2021 (UTC)
thread_title: Fortran ambiguity

message: In first paragraph note that a commonly desired side-effect is assignment.
The examples given are somewhat confusing.
This article is about imperative programming languages so can omit mention of Lisp and functional languages.
Should keep mention that <statement is executed while expression is evaluated>.
I'm inclined to remove the discussion of Python.
:I agree -- that section should be completely re-written. Using print and assignment as examples is perverse. Yes, there are languages where print is a function, and languages where it is a statement; yes, there are languages where an assignment can be part of an expression. But better to start with the simple cases. The Python business is off-topic and confusing. "We have only seen...", "we'll see shortly", and "if you ask Python..." are not WP style. --Macrakis (talk) 22:16, 9 March 2021 (UTC)
thread_title: Comments on the above

message: The above "Proposed new wording" (which appears to now be the current wording) is simply wrong. No statements in C or C++ evaluate to any value. In the example given, j = 0 is an *expression* and not a statement, which is the reason is it allowed on the right side of the assignment operator. i = j = 0; is a statement and it does not evaluate to any value, void or otherwise. Consider the following *invalid* code example:
i = (j = 0;);
This will always result in a compiler error because the *statement* j = 0; does not evaluate to a value, so it cannot be used to assign to i.
Note the difference between expression: j = 0 and statement: j = 0;. Just because statements can be constructed of an expression (which returns a value) followed by a statement terminator (semicolon) it does *not* mean that the statement returns a value.
Additionally, is "simple finger trouble" normal parlance? I have never heard it before, and I am afraid to Google it to find out.
63.115.17.182 (talk) 20:46, 17 October 2022 (UTC)
thread_title: Comments/Objection to the above