Questions tagged [language-design]

A tag for questions related to the design of any aspect of programming languages.

1363 questions
29
votes
4 answers

Are there languages without "null"?

There are many people who think that the concept of the special value null (as it is used in lanuages like C, Java, C#, Perl, Javascript, SQL etc.) is a bad idea. There are several questions about this on SO and P.SE, such as Best explanation for…
sleske
  • 81,358
  • 34
  • 189
  • 227
29
votes
9 answers

How is a reference different from a pointer in implementation?

Possible Duplicate: Difference between pointer variable and reference variable in C++ I am reading about the book "Inside the C++ Object Model" by Stanley Lippman. What puzzles me is the difference between a "reference" of an object and a…
smwikipedia
  • 61,609
  • 92
  • 309
  • 482
29
votes
1 answer

Are there good reasons for 'private' to work the way it does in Ruby?

It took me a while to understand how private methods work in Ruby, and it really strikes me as being very awkward. Does anyone know if there are good reasons for private methods to be handled the way they are? Is it just historic reasons? Or…
MiniQuark
  • 46,633
  • 36
  • 147
  • 183
29
votes
3 answers

Syntax for universal references

This is an rvalue reference: void foo(int&& a); It does not bind to lvalues: int i = 42; foo(i); // error This is a universal reference: template void bar(T&& b); It binds to rvalues and it also binds to lvalues: bar(i); //…
fredoverflow
  • 256,549
  • 94
  • 388
  • 662
28
votes
5 answers

C++: rationale behind hiding rule

What's the rationale behind the hiding rule in C++? class A { void f(int); } class B : public A { void f(double); } // B::f(int) is hidden If it is a meaningful feature I think it should also be possible to hide functions without defining new…
peoro
  • 25,562
  • 20
  • 98
  • 150
28
votes
3 answers

Why is System.Net.Http.HttpMethod a class, not an enum?

HttpStatusCode is implemented as an enum, with each possible value assigned to its corresponding HTTP status code (e.g. (int)HttpStatusCode.Ok == 200). However, HttpMethod is implemented as a class, with static properties to get instances for the…
Tomas Aschan
  • 58,548
  • 56
  • 243
  • 402
28
votes
5 answers

Is there a specific reason nested namespace declarations are not allowed in C++?

The standard does not allow code like this: namespace Hello::World { //Things that are in namespace Hello::World } and instead requires namespace Hello { namespace World { //Things that are in namespace Hello::World }} What is the rationale?…
Billy ONeal
  • 104,103
  • 58
  • 317
  • 552
28
votes
2 answers

When to use " " ( space ) and when to use . ( dot ) when invoking methods in Scala?

I've seen Scala using both interchangeably, but I don't know when to use one or the other. Is there a convention? For instance these are equivalent "hello" toString and "hello".toString() And they can even be mixed "hello".toString() length…
OscarRyz
  • 196,001
  • 113
  • 385
  • 569
28
votes
2 answers

C# Language Design: method group inside `is` operator

I'm interesting in some design choices of C# language. There is a rule in C# spec that allows to use method groups as the expressions of is operator: class Foo { static void Main() { if (Main is Foo) Main(); } } Condition above is always false,…
controlflow
  • 6,667
  • 1
  • 31
  • 55
28
votes
2 answers

What does Eric Lippert mean by "you need to know what the base class is to determine what the base class is"?

I just read this interesting article by Eric Lippert, Top 10 Worst C# Features. Near the end he states: The rules for resolving names after the aforementioned colon are not well founded; you can end up in situations where you need to know what …
Ian Newson
  • 7,679
  • 2
  • 47
  • 80
28
votes
11 answers

How can you extend Java to introduce passing by reference?

Java is pass-by-value. How could you modify the language to introduce passing by reference (or some equivalent behavior)? Take for example something like public static void main(String[] args) { String variable = "'previous String reference'"; …
28
votes
2 answers

Why can't namespaces be template parameters?

I understand that namespaces cannot be template parameters. See the question, "template specialized on a namespace": Given: namespace A { class Foo; class Bar; } namespace B { class Foo; class Bar; } I want to template a class on the…
Alex
  • 6,843
  • 10
  • 52
  • 71
28
votes
6 answers

Why doesn't C# support const on a class / method level?

I've been wondering for a while why C# doesn't support const on a class or a method level. I know that Jon Skeet have wanted support for immutability for a long time, and I recon that using the C++ syntax of function const could aid in that. By…
cwap
  • 11,087
  • 8
  • 47
  • 61
27
votes
9 answers

What would Clojure lose by switching away from leading parenthesis like Dylan, Julia and Seph?

Three lispy homoiconic languages, Dylan, Julia and Seph all moved away from leading parenthesis - so a hypothetical function call in Common Lisp that would look like: (print hello world) Would look like the following hypothetical function…
hawkeye
  • 34,745
  • 30
  • 150
  • 304
27
votes
4 answers

Java static imports

Just by experiment I discovered that Java non static methods overrides all same named methods in scope even at static context. Even without allowing parameter overloading. Like import java.util.Arrays; import static…
Stan Kurilin
  • 15,614
  • 21
  • 81
  • 132