Questions tagged [language-construct]

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.

In simpler terms, it is the syntax/way a programming language is written. However we do not recommend using this tag in this general semantic meaning as the general keyword syntax would fit it better.

55 questions
364
votes
7 answers

?: operator (the 'Elvis operator') in PHP

I saw this today in some PHP code: $items = $items ?: $this->_handle->result('next', $this->_result, $this); I'm not familiar with the ?: operator being used here. It looks like a ternary operator, but the expression to evaluate to if the predicate…
alpha_juno
  • 3,643
  • 2
  • 16
  • 6
93
votes
4 answers

What is the difference between a language construct and a "built-in" function in PHP?

I know that include, isset, require, print, echo, and some others are not functions but language constructs. Some of these language constructs need parentheses, others don't. require 'file.php'; isset($x); Some have a return value, others do…
Philippe Gerber
  • 17,457
  • 6
  • 45
  • 40
87
votes
3 answers

What is ?: in PHP 5.3?

Possible Duplicate: What are the PHP operators “?” and “:” called and what do they do? From http://twitto.org/
JasonDavis
  • 48,204
  • 100
  • 318
  • 537
73
votes
4 answers

How can I emulate destructuring in C++?

In JavaScript ES6, there is a language feature known as destructuring. It exists across many other languages as well. In JavaScript ES6, it looks like this: var animal = { species: 'dog', weight: 23, sound: 'woof' } //Destructuring var…
Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
58
votes
6 answers

Is there a way to implement custom language features in C#?

I've been puzzling about this for a while and I've looked around a bit, unable to find any discussion about the subject. Lets assume I wanted to implement a trivial example, like a new looping construct: do..until Written very similarly to…
Thebigcheeze
  • 3,408
  • 2
  • 22
  • 18
34
votes
11 answers

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…
KawaiKx
  • 9,558
  • 19
  • 72
  • 111
26
votes
6 answers

Specifying default parameter when calling C++ function

Suppose I have code like this: void f(int a = 0, int b = 0, int c = 0) { //...Some Code... } As you can evidently see above with my code, the parameters a,b, and c have default parameter values of 0. Now take a look at my main function…
Arnav Borborah
  • 11,357
  • 8
  • 43
  • 88
20
votes
8 answers

Why would I use java.lang.Class.cast

I recently stumbled upon a piece of code that went like this: Object o = .. ; Foo foo = Foo.class.cast(o); I was actually not even aware that java.lang.Class had a cast method, so I looked into the docs, and from what I gather this does simply do a…
Jan Thomä
  • 13,296
  • 6
  • 55
  • 83
20
votes
7 answers

PHP: What are language constructs and why do we need them?

I keep coming across statements like: echo is a language construct but print is a function and hence has a return value and die is a language construct My question is what are these language constructs and more importantly why do we need them?
Zacky112
  • 8,679
  • 9
  • 34
  • 36
17
votes
20 answers

C++ constructs replacing C constructs

After discussing with a newly arrived developer in my team, I realized that there are still, in C++, habits of using C constructs because they are supposed to be better (i.e. faster, leaner, prettier, pick your reason). What are the examples worth…
paercebal
  • 81,378
  • 38
  • 130
  • 159
14
votes
3 answers

Questions on a Haskell -> C# conversion

Background: I was "dragged" into seeing this question: Fibonacci's Closed-form expression in Haskell when the author initially tagged with many other languages but later focused to a Haskell question. Unfortunately I have no experience whatsoever…
Jeff Mercado
  • 129,526
  • 32
  • 251
  • 272
14
votes
2 answers

Python: Any way to declare constant parameters?

I have a method: def foo(bar): # ... Is there a way to mark bar as constant? Such as "The value in bar cannot change" or "The object pointed to by bar cannot change".
Nick Heiner
  • 119,074
  • 188
  • 476
  • 699
11
votes
2 answers

What does 'String...' mean?

In the code: public interface ProductInterface { public List getProductPricing(ProductVO product, ProductVO prodPackage, String... pricingTypes) throws ServiceException; } What does String... pricingTypes mean? What type of…
David Silva
  • 1,939
  • 7
  • 28
  • 60
8
votes
5 answers

When and Why use Loop Do Construct in Ruby

I recently came up across a problem/solution that used Loop Do. I seldom have seen this so far in my learning Ruby Programming (I am a beginner with no CS experience). # Write a function, `nearest_larger(arr, i)` which takes an array and…
JaTo
  • 2,742
  • 4
  • 29
  • 38
8
votes
3 answers

What is the difference between echo with braces and without braces, and why do both methods exist?

I think most of us that program in php learned to echo "string";. While common, I am wondering why we use this so different then any other function. So why do we do: echo "Some String"; Instead of echo("Some String"); And why do both exist and…
Damien Overeem
  • 4,487
  • 4
  • 36
  • 55
1
2 3 4