57 questions
-1 votes
1 answer
86 views
What is the programming construct in Python of passing some arguments in front of a constructor call? How to interpret parameters passed to an object? [duplicate]
In the below code line, if I am not mistaken, we are creating the object of the class layer.Dense from tensorflow.keras and then passing some arguments to the object in the parethesis. x = layers....
4 votes
0 answers
232 views
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 ...
4 votes
1 answer
293 views
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 ...
0 votes
1 answer
46 views
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; ...
2 votes
2 answers
72 views
Does PHP have a facility to reduce the duplication of parameter declaration and initialization in the class and the constructor?
Consider writing the class below: class SomeClass { /** @var array */ private $files; /** @var string */ private $productName; /** @var bool */ private $singlePage; /** ...
0 votes
1 answer
46 views
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 ...
2 votes
2 answers
867 views
What does "array_expression" mean in php?
http://php.net/manual/en/control-structures.foreach.php Trying to better understand the foreach loop. In the documentation above it states "The first form loops over the array given by ...
2 votes
1 answer
1k views
C# equivalent of C++ std::vector<int>.end()
I was trying to rewrite some C++ code I found on the internet in C# for my hexagon sphere project, but I ran into the following code: if((((*ti)->m_hexA) != tileNdx) && (find(nbrs. begin(),...
1 vote
0 answers
144 views
What is the purpose of this case label?
Inside boost/asio/coroutine.hpp there is case statement inside the definition of the macro yield which seems to be inaccessible: switch (_coro_value ? 0 : 1) \ for (;;) \ case -1: if (...
30 votes
6 answers
18k views
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 ...
1 vote
1 answer
801 views
Is the Scala `match` construct syntactic sugar? If so, how does is work?
In trait Expr case class Number(n: Int) extends Expr case class Sum(e1: Expr, e2: Expr) extends Expr object CaseExample { def eval(e: Expr): Int = e match { case Number(n) => n case Sum(...
1 vote
2 answers
58 views
PHP Declarator In If-Statement Scope
This is pretty basic. Let's say you define a variable in an if statement if($stmt = $db->prepare($sql)) { // do stuff } Can I access $stmt below the if statement? Or does $stmt need to be ...
1 vote
1 answer
109 views
Can I use variable functions with language constructs?
This question here kinda address the issue. In my case I would like to call a function like empty() or is_int(). For example: <?php $foo = 'empty'; $test = NULL; $foo($test); This ...
81 votes
4 answers
34k views
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', ...
0 votes
0 answers
105 views
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 = # ...