KawaiKx
KawaiKx

Reputation: 9920

What does 'Language Construct' mean?

I am learning C from 'Programming in C' by Stephen Kochan.

Though the author is careful from the beginning only not to confuse the students with jargon, but occasionally he has used few terms without explaining their meaning. I have figured out the meaning of many such terms with the help of internet.

However, I could not understand the exactly meaning of the phrase 'language construct', and unfortunately the web doesn't provide a good explanation.

Considering I am a beginner, what does 'language construct' mean?

Upvotes: 37

Views: 27331

Answers (11)

sakhunzai
sakhunzai

Reputation: 14470

First, you must understand what a Formal Language is. All programming languages are formal languages (read the reference). You may then read a little bit about compiler construction, including this reference as well.

Going back to your question, consider this: The English language (a natural language) has tokens 'A-Z/0-9/,;"...' which we use to build "words" and we use languages rules to build sentences out of words. So, in the English language, a construct is what we build out of tokens.

Consider this brick-and-mortar example: Imagine if you set out to build a house, the basic materials you might use are: sand, iron, wood, cement, water (just five for simplicity). Anything you build out of these 4 or 5+ items would be a "construct", which in turn helps you build your house.

I have intentionally omitted details to further simplify the answer; hope this is helpful.

Upvotes: 45

mandober
mandober

Reputation: 1

A language construct is a piece of syntax that the compiler has intimate knowledge about, usually because it needs to handle it specially. Typical examples of language constructs are the short-circuiting operators found in many imperative languages. Because these operators require lazy evaluation in an otherwise eager language, they must be handled specially by the compiler.

So, a stricter definition of a language construct may be: a syntactical form that is handled specially by the compiler, having functionality that cannot be implemented by a user.

Upvotes: 0

Yagnasree.Bobbara
Yagnasree.Bobbara

Reputation: 1

Language construct is a piece of language syntax.

Example:

A declaration of a variable is a language construct:

{
int a; // declaration of a variable "a"
}

Upvotes: 0

drmaa
drmaa

Reputation: 3674

Language constructs according to the GCSE book are basic building block of a programming language. that are

1. Sequential,     
2. Selection, if, if/else    
3. Iteration, while, for  

Upvotes: 0

aquasan
aquasan

Reputation: 374

They are the base units from which the language is built up. They can't be used as a function rollback. They are directly called by the parser. It includes all the syntax, semantics and coding styles of a language. For more clarification you may refer to this question.

Upvotes: 6

Ravi Kumar
Ravi Kumar

Reputation: 9

C is a structural language so while compiling your code everything thing goes statement by statement. Thus it becomes necessary to place your statement properly. This placing i.e. putting your statement correctly is your language construct else there may be syntax error or logical error.

Upvotes: -1

Kuldeep Dangi
Kuldeep Dangi

Reputation: 4432

In reference to a programming language

    Language Constructs mean the basic constructs of a programming languge e.g
1. Conditions (if, else, switch)
2. Loops (For, While, Do-while) etc

Upvotes: 1

fruqi
fruqi

Reputation: 5353

Let say you want to create a class containing methods and properties, so:

Construct is an architecture of a class you are about to create. The architecture of the class consists of methods and properties created by you by using predefined utilities (such as: 'if', 'else', 'switch', 'break', etc)

That's my take on construct.

Upvotes: 1

Wikipedia definition:

A language construct is a syntactically allowable part of a program that may be formed from one or more lexical tokens in accordance with the rules of a programming language. The term Language Constructs is often used as a synonym for control structure, and should not be confused with a function.

Upvotes: 5

ctt
ctt

Reputation: 1435

A language construct is a piece of language syntax. For example, the following is a language construct in C that lets you control the flow of a program:

if ( condition ) {
  /* when condition is true */
} else {
  /* when condition is false */
}

They usually use the term language construct because these are parts of most programming languages, but may be written differently, depending on the language. For example, a similar language construct in bourne shell would be:

if COMMAND; then
  # when command returns 0
else
  # when command returns anything else
fi

The function of this construct is the same, however, the way it's written is a bit different.

Hope this helps. If you need more detail, you may want to do a bit more research. As one of the comments suggests, Wikipedia may be helpful.

Upvotes: 11

hofnarwillie
hofnarwillie

Reputation: 3660

Without seeing the context that the phrase is used in, I cannot be sure, but generally the phrase 'language construct' just means the combination of keywords, grammar and structure of a coding language. Basically, how to format/write/construct a piece of code.

Upvotes: 4

Related Questions