Talk:Statement (computer science)
|WikiProject Computer science||(Rated Start-class, Mid-importance)|
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)
Pascal is not case sensitive (although some implementations provide an option to make it so). It is true that most source code + books use lower case. Having written Pascal using a terminal that did not support lower case I don't find reading upper case Pascal a jarring experience. Others might.
Derek farn 19:36, 16 February 2006 (UTC)
"Most programming languages"
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)
- 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)
- 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)
- 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)
Create new statements during program execution?
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)
Use of "declaration" and "definition"
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 22.214.171.124 (talk) 17:44, 8 October 2008 (UTC)
Statement syntax and the definition of statements in standard documents
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).
- 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)
- 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)
It is correct that the syntax/semantics of statements is specified by the defn of the PL (as every other aspect of a PL). But there is usually also a generic function call or method call syntax. Inside this frame of function and method definitions new functions and methods can be introduced. Since statements are usually outside this frame (and not a function call) the programmer is not able to introduce new ones (asside from languages with closures such as LISP). BTW is it really to hard to improve some paragraphs instead of just removing them? Georg Peter (talk) 14:57, 8 August 2010 (UTC)
- 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)