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
8
votes
5 answers

How can I use C# style enumerations in Ruby?

I just want to know the best way to emulate a C# style enumeration in Ruby.
fooledbyprimes
  • 999
  • 1
  • 11
  • 29
8
votes
4 answers

Is this special treatment of exit and die documented in PHP?

I've just read the page on Expressions in the PHP docs, and right at the top it says: The simplest yet most accurate way to define an expression is "anything that has a value". That simple definition includes all functions and most language…
Paul
  • 139,544
  • 27
  • 275
  • 264
7
votes
6 answers

Are there any other uses of parenthesis in powershell?

As new to Powershell world, sometime I'm stuck in the tricky syntax. That's why I'm trying to figure out all the possible uses of the parenthesis inside the language. Do you know some more? Can you add here? Here mine (left out basic use of curly in…
Emiliano Poggi
  • 24,390
  • 8
  • 55
  • 67
7
votes
3 answers

Use constant as class name

I need to use constant as class name for acces to this class static property, that is class a { public static $name = "Jon"; } define("CLASSNAME", "a"); echo CLASSNAME::$name; this returns error, that class CLASSNAME not exists. There is…
Oto Shavadze
  • 40,603
  • 55
  • 152
  • 236
6
votes
3 answers

What does var {u,v,w} = x; mean in Javascript?

I have seen this in a piece of JS code: var {status, headers, body} = res; What does it do?
jd.
  • 4,057
  • 7
  • 37
  • 45
6
votes
3 answers

How to Subtract Bytes on One Line in C#

This is really odd. Can anyone explain this? This code does NOT work: const byte ASC_OFFSET = 96; string Upright = "firefly"; byte c7 = (byte)Upright[6] - ASC_OFFSET; //Cannot implicitly convert type 'int' to 'byte'. This code also does NOT…
Flipster
  • 4,373
  • 4
  • 28
  • 36
6
votes
3 answers

In PHP, why wasn't echo implemented as a function? (not echo vs. printf)

I'm just curious. In PHP, why wasn't echo implemented as a function? Why didn't PHP just give us printf and never tell about echo? Please note that: This is not a question about echo vs. printf. I already knew that echo is a language…
user168237
6
votes
3 answers

What precisely is a construct in JavaScript?

As I learn JavaScript I've been looking around the web and seen numerous references to constructs in Javascript, but I can't seem to find a complete definition of what they are and what they are not, especially in the context of Javascript. For…
5
votes
2 answers

Why does Scala support shadow variables?

I think that shadow variables are too dangerous to use them. Why does Scala support this language construct? There should be some strong reason for that, but I cant find it.
Igor Soloydenko
  • 11,067
  • 11
  • 47
  • 90
5
votes
41 answers

On your very first program, which construct hooked you on programming?

To me it was the If statement, I'm psyched up, since then I believed that computers are very intelligent, or I can at least make it appear intelligent because of it.
Michael Buen
  • 38,643
  • 9
  • 94
  • 118
4
votes
0 answers

Variable Overloading

This question originated in a discussion with a colleague and it is purely academic. Is there any programming language that has variable overloading? In Java and many other languages, there is function overloading, where multiple functions/methods…
Dakkaron
  • 5,930
  • 2
  • 36
  • 51
4
votes
1 answer

What is a language construct? How (theoreticaly) it is being implemented in C?

I am familiar with how PHP functions are mapped to functions in C in the C code beneath PHP. I know in C what a function means and what a MACRO() means. I do not understand what is a language construct, like echo, in PHP means.
Itay Moav -Malimovka
  • 52,579
  • 61
  • 190
  • 278
4
votes
1 answer

Where is PHP echo implemented in the source?

You can lookup built-in functions by searching for e.g. PHPAPI(stream_copy_to_stream) and find the implementation in ext/standard/streamsfuncs.c. How to do that for a language construct like echo? I found it is associated with T_ECHO in…
cachius
  • 1,743
  • 1
  • 8
  • 21
3
votes
5 answers

Advanced constructs in Javascript

I found one interesting project on github which deals with pdf rendering in the browser. I tried to read the code because I'm interested in this topic but I realized that my javascript knowledge is poor (insuficient). There are constructs like: var…
xralf
  • 3,312
  • 45
  • 129
  • 200
3
votes
4 answers

Is there a language construct similar to PHPs list() in C#?

PHP has a language construct list() which provides multiple variables assignment in one statement. $a = 0; $b = 0; list($a, $b) = array(2, 3); // Now $a is equal to 2 and $b is equal to 3. Is there a similar thing in C#? If not, is there any…
Arseni Mourzenko
  • 50,338
  • 35
  • 112
  • 199