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

How a variable and its reference is stored and accessed in computer memory?

How is a variable stored in a computer memory ? For example: when we specify int x = 15; Typically the computer in its ram allocates a 4 bytes chunk of memory, storing the value 15 in the form of 0's and 1's in the allocated 4 bytes and x refers to…
4
votes
2 answers

Understanding foldLeft with Map instead of List

I fould like to understand how foldLeft works for Maps. I do understand how it works if I have a List and call on it foldLeft with a zero-element and a function: val list1 = List(1,2,3) list1.foldLeft(0)((a,b) => a + b) Where I add the zero-element…
Make42
  • 12,236
  • 24
  • 79
  • 155
4
votes
2 answers

How is possible to apply toUpperCase() on an empty String in Java?

I've thought that if I run this System.out.println("toUpperCase() on empty String:"+ "".toUpperCase()); and it returns an empty String. How is that possible? toUpperCase() should fail in this case isn't it? Thanks!
GniruT
  • 731
  • 1
  • 6
  • 14
4
votes
1 answer

In Javascript is an array literal an object?

I'm reading the JavaScript The Definitive Guide and it says: The easiest way to create an array is with an array literal But then it says: Another way to create an array is with the Array() constructor. My question is, no matter how we declare…
GniruT
  • 731
  • 1
  • 6
  • 14
4
votes
8 answers

What are some examples of where using parentheses in a program lowers readability?

I always thought that parentheses improved readability, but in my textbook there is a statement that the use of parentheses dramatically reduces the readability of a program. Does anyone have any examples?
Brandon Tiqui
  • 1,429
  • 3
  • 17
  • 35
3
votes
0 answers

A language that has function scoped, class life time variable

After asking this question, I just wondered is there any language that has this concept. Consider this piece of arbitrary code: class Foo { void bar() { static int i = 0; print(i++); } } Foo foo = new Foo(); foo.bar(); //…
isamert
  • 482
  • 4
  • 12
3
votes
4 answers

When and how is it decided to either use a cast or not?

I was going through the, "Multiple Inheritance for C++ by Bjarne Stroustrup, Published in the May 1999 issue of "The C/C++ Users Journal"". The below excerpt is from the same (Page 5/17), 4.4 Casting Explicit and implicit casting may also involve…
Abhineet
  • 5,320
  • 1
  • 25
  • 43
3
votes
3 answers

Can we have more error (messages)?

Is there a way, in R, to pop up an error message if a function uses a variable not declared in the body of the function: i.e, i want someone to flag this type of functions aha<-function(p){ return(p+n) } see; if there happens to be a "n" variable…
user189035
  • 5,589
  • 13
  • 52
  • 112
2
votes
1 answer

Rust equivalent of concurrent code written in Go?

I'm stuck at doing multithread feature in Rust. I'm trying to do translate my code written in Go that updates a map's value while iterating and make a new thread. (simplified codes) my_map := make(map[string]string) var wg…
alfex4936
  • 311
  • 3
  • 10
2
votes
1 answer

Why is memory utilization continuiously increasing when using dependency injection in a C# console application?

I may know the answer to my posted question: I'm using constructor dependency injection throughout the entire application which is a looped C# console application that does not exit after each request. I suspect the life time of all of the included…
2
votes
1 answer

What is the name for the concept that "eval" is?

I'm looking for the name of the programming concept that eval is---eval being the function which executes a string as an expression. I'm interested in the term for both executing raw strings in code eval('print("hello")'), and also from file, like…
Mittenchops
  • 18,633
  • 33
  • 128
  • 246
2
votes
1 answer

Shallow Copy and Move in rust

Is is possible for rust to have shallow copies, because it would appear that a move replaces a shallow copy?
roberthayek
  • 167
  • 2
  • 10
2
votes
1 answer

What is the difference (in terms of idea) of mode, storage.mode, typeof in R?

My research so far Most articles discuss the difference between class and typeof but I haven't found much to the differences between mode, storage.mode, and typeof. I get that mode, storage.mode, and typeof are more similar and class is more…
Make42
  • 12,236
  • 24
  • 79
  • 155
2
votes
2 answers

Is this a good programming practice? if condition on a method that returns a bool with a callback

I'm using Objective-C for this question but this is not really language specific. I have following method in my User class, +(BOOL)canPerform:(NSString *)string withCompletion:(void(^)(BOOL success,NSError *error))block; In my…
Rukshan
  • 7,902
  • 6
  • 43
  • 61
2
votes
2 answers

Circular Queue theory

I'm need help understanding the Circular Queue concept. I read a couple post on stackoverflow and none of the answers are answering a mental block I'm having. For example say I have 8 cells in a Circular Queue. Head …