Questions tagged [language-concepts]

Use this tag to ask about how a particular idea (arrays, lists, tables, search, sort) is implemented in language X or how to understand a basic part of the language.

Often there is a particular concept that isn't quite grouped into any of the other tags, or it is just too embarrassing because it's a "newbie" idea. Or there isn't a concrete problem to solve and you were just wondering about how something works in language X.

If you wanted to ask about which version of the moot() function is used if class A is inherited from class B and implements C, tag it with inheritance..

But also use this tag to point out it's more of a "Hmm..." question than a "How do I solve this" question.

98 questions
1
vote
2 answers

Why is LockSupport provided by Java but not useful

Strangely, Java Doc says: These methods are designed to be used as tools for creating higher-level synchronization utilities, and are not in themselves useful for most concurrency control applications. Is there any example/scenario to…
xmllmx
  • 39,765
  • 26
  • 162
  • 323
1
vote
1 answer

When to explicitly state types of inputs of functions?

I am able to calculate the mean word length per starting letter for the spark collection val animals23 = sc.parallelize(List(("a","ant"), ("c","crocodile"), ("c","cheetah"), ("c","cat"), ("d","dolphin"), ("d","dog"), ("g","gnu"), ("l","leopard"),…
Make42
  • 12,236
  • 24
  • 79
  • 155
1
vote
1 answer

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(e1, e2) => eval(e1) + eval(e2) } def main(args:…
Make42
  • 12,236
  • 24
  • 79
  • 155
1
vote
0 answers

PHP: How to properly copy a primitive to a new memory address

I had an issue recently (PHP: variable value mysteriously set to 0) where a variable was being passed by value into a PHP function, and somehow the value of that variable was changed, like so: $var = 'hello'; some_function($var); echo $var; //…
1
vote
3 answers

Named Parameters used outside of class

I understand in C# there is such thing as named parameters so that is a bit misleading. The question I have is what they should be called in general. In my time using libraries in other languages I've sometimes run across predefined values that can…
1
vote
1 answer

How can I show this grammar is ambiguous?

T-->iSS |iS S--> n | T I tried to show like this T->iSS->inS->inn T->iS->iT->iiSS->iinS->iinn how can I fix this?
1
vote
1 answer

Unexpected syntax error on method type parameter

Why is this causing compilation error: public void addImplements(Class cl) whereas this is OK: public void addImplementedBy(Class cl) T is a type parameter specified on the class. Error message on the first is…
geert3
  • 7,086
  • 1
  • 33
  • 49
1
vote
2 answers

Why do callbacks functions allow us to do things asynchronously in Javascript?

I've read that callbacks make JavaScript asynchronously. But I'm not sure if I understood the explanation. This is what I get Callback functions allow us to do things asynchronously, since they ensure that the lines prior to the callback are…
GniruT
  • 731
  • 1
  • 6
  • 14
1
vote
3 answers

How do function-objects fit in the definition of objects in JavaScript?

I've read that an object is a collection of properties and methods. Then if a function is an object, how do function-objects fit in the definition of objects in JavaScript? I'm trying to make an example of a Function with properties and functions…
GniruT
  • 731
  • 1
  • 6
  • 14
1
vote
4 answers

Java, Class objects that have different methods to each other?

This may seem like an odd question, but I'm trying to practice writing reusable code, or least trying to practice thinking about it in the right way, if you know what I mean? I have an assignment that involves writing a text interface with a couple…
user3593486
  • 47
  • 2
  • 7
1
vote
3 answers

Understanding basic variable concepts

I'm having difficulties understanding the swapping of variables. There are many helpful threads explaining how to actually do it, but I am having difficulties understanding it. The example I'm talking about is: var a = 1; b = 2; c = a; a =…
user2579657
1
vote
1 answer

Design consideration of C++ dynamic_cast of also examining the pointer or reference type

When we are doing dynamic cast: A* x = ...; B* b = dynamic_cast(x); The dynamic_cast will return valid pointer only when: A is polymorphic, otherwise compilation fails. B is equivalent to A or is derived from A B should have a relationship…
1
vote
5 answers

iOS >> Protocols & Delegates Concepts

There are a lot of materials about Protocols & Delegates on the web, and different tutorials call some of the "participants" in the process by different names. especially confusing is the "Adaptor" and the "Conformer" concepts. I understand that the…
Ohad Regev
  • 5,641
  • 12
  • 60
  • 84
1
vote
2 answers

Images for Assembler, Interpreter and Compiler?

I got an assignment to make hand-drawn posters of Assembler Interpreter Compiler I googled for images of above three but not able to get some exact images which can define the above three properly. Can anyone share some image links which will give…
djmzfKnm
  • 26,679
  • 70
  • 166
  • 227
1
vote
6 answers

Correct usage of Java System.currentTimeMillis() method?

I am comparing the time to compute both iterative and recursive factorial procedures in Java. I am trying to use the System.currentTimeMillis method to compare the time it takes for each algorithm to compute, but I can't seem to calculate the…
dtg
  • 1,803
  • 4
  • 30
  • 44