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
0
votes
1 answer

Can I use an implicit class name in Dart?

Is there any way to avoid having to explicitly specify a class name in Dart, when using it multiple times? Let's say I have something like class VehicleType{ static const int BICYCLE = 0; static const int CAR = 1; static const…
Magnus
  • 17,157
  • 19
  • 104
  • 189
0
votes
1 answer

How can few entities be used in different manner? What are those entities actually called?

I'm learning PHP. While learning PHP, I noticed that there are few entities in PHP which are used in different fashion. Sometimes with the pair of parenthesis with the enclosing parameter/s between them, sometimes with the pair of blank…
PHPLover
  • 1
  • 51
  • 158
  • 311
0
votes
0 answers

ruby construct for preserving original value of a variable after block execution

Sometimes I need to preserve the original value of a variable, do stuff and then restore its original value kind of like this: def method original_value = @variable @variable = true result = # Do stuff @variable = original_value …
e.nikolov
  • 127
  • 1
  • 11
0
votes
4 answers

Does JavaScript have a language construct similar to the php list command?

Does JavaScript have a language construct or something similar to the php list command? http://php.net/manual/en/function.list.php This command will assign the values of an array to variables in a single statement. For example, given the…
ciso
  • 2,887
  • 6
  • 33
  • 58
0
votes
6 answers

Does there exist a shorter if statement in PHP?

Is it possible to rewrite this to be shorter somehow? if (isset($_POST['pic_action'])){ $pic_action=$_POST['pic_action']; } else { $pic_action=0; } I have seen it somewhere but forgot... :/ BTW, please explain your code also if you…
user188962
0
votes
1 answer

ECHO does not work in the third exp of FOR LOOP but PRINT does work?

Why is this valid: for ($i = 0; $i < 10; print $i++); and this gives syntax error: for ($i = 0; $i < 10; echo $i++); What's the difference? Both are language constructs. Is there a rule what is valid and what not?
learning php
  • 1,134
  • 2
  • 10
  • 14
0
votes
9 answers

Is there a programming language that allows variable declaration at call site?

Update 2: examples removed, because they were misleading. The ones below are more relevant. My question: Is there a programming language with such a construct? Update: Now when I think about it, Prolog has something similar. I even allows defining…
Łukasz Lew
  • 48,526
  • 41
  • 139
  • 208
-1
votes
2 answers

What does the following operator - (? do something : do something) mean?

What does the following code do? Tracker t = (trackerId == TrackerName.APP_TRACKER) ? analytics.newTracker(PROPERTY_ID) : (trackerId == TrackerName.GLOBAL_TRACKER) ? analytics.newTracker(R.xml.global_tracker) :…
ARK
  • 3,734
  • 3
  • 26
  • 29
-1
votes
1 answer

How can I run a method from an object's parent class that has been overridden in PHP?

This may be a duplicate post, but searching for the answer just led me to the C, Java and ColdFusion ways of doing this... Given class A with method foo() and class B extends A and also has foo(), I want to run something like: $b = new…
thatthatisis
  • 783
  • 7
  • 18
-2
votes
1 answer

What are the different ways to implement a Singleton Design Pattern in C# based on situations

What are possible different ways using various language constructs to implement a Singleton pattern in C# and in which situation each solution is used? What are the advantages and disadvantages of each implementation? and, which is the best one of…
S2S2
  • 8,322
  • 5
  • 37
  • 65
1 2 3
4