Language construct: Difference between revisions

Content deleted Content added
Examples of language constructs: got rid of superfluous "for example"
Covert23 (talk | contribs)
m basic grammar clarification
Tags: Visual edit Mobile edit Mobile web edit
 
(24 intermediate revisions by 22 users not shown)
Line 1:
{{Short description|Syntactically valid part of a program formed from lexical tokens}}
{{Unreferenced stub|auto=yes|date=December 2009}}
{{More sources|date=January 2021}}
 
AIn [[computer programming]], a '''language construct''' is "a [[syntaxSyntax (programming languages)|syntactically]] allowable part of a [[Computer program|program]] that may be formed from one or more [[lexical token]]s in accordance with the rules of athe [[programming language]]", as defined by in the [[ISO/IEC 2382]] standard ([[ISO/IEC JTC 1]]).<ref name="ISO/IEC 2382">{{cite web |title=ISO/IEC 2382, Information technology — Vocabulary |url=https://www.iso.org/obp/ui/#iso:std:iso-iec:2382:ed-1:v1:en}}</ref>
A '''term''' is defined as a "linguistic construct in a [[conceptual schema]] language that refers to an entity".<ref name="ISO/IEC 2382"/>
A '''language construct''' is a [[syntax|syntactically]] allowable part of a [[Computer program|program]] that may be formed from one or more [[lexical token]]s in accordance with the rules of a [[programming language]].
 
While the terms "language construct" and "control structure" are often used synonymously, there are additional types of logical constructs within a computer program, including [[variable (computer science)|variables]], [[expression (computer science)|expressions]], [[function (computer science)|functions]], or [[modular programming|modules]].
The term Language Constructs is often used as a synonym for control structure, and should not be confused with a function.
 
[[Control flow]] statements (such as [[Conditional (computer programming)|conditionals]], [[foreach loop]]s, [[while loop]]s, etc) are language constructs, not [[Subroutine|function]]s. So <code>while (true)</code> is a language construct, while <code>add(10)</code> is a function call.
 
==Examples of language constructs==
In [[PHP]] <code>print</code> is a language construct.<ref>{{Cite [httpweb |title=PHP: print - Manual |url=https://www.php.net/manual/en/function.print.php] |access-date=2022-11-18 |website=www.php.net}}</ref>
<sourcesyntaxhighlight lang="php">
<?php
print 'Hello world';
?>
</syntaxhighlight>
</source>
 
is the same as:
 
<sourcesyntaxhighlight lang="php">
<?php
print('Hello world');
?>
</syntaxhighlight>
</source>
 
{{DEFAULTSORT:Language Construct}}
[[Category:Programming constructs]]
 
In Java a [[class (computer programming)|class]] is written in this format:<syntaxhighlight lang="java">
public class MyClass {
//Code . . . . . .
}
</syntaxhighlight>
 
In C++ a class is written in this format:<syntaxhighlight lang="c++">
{{Compu-lang-stub}}
class MyCPlusPlusClass {
//Code . . . .
};
</syntaxhighlight>
==References==
{{reflist}}{{Compu-lang-stub}}