A tag for questions related to the design of any aspect of programming languages.
Questions tagged [language-design]
1363 questions
97
votes
8 answers
Factors in R: more than an annoyance?
One of the basic data types in R is factors. In my experience factors are basically a pain and I never use them. I always convert to characters. I feel oddly like I'm missing something.
Are there some important examples of functions that use…

JD Long
- 59,675
- 58
- 202
- 294
96
votes
7 answers
Can't set attributes on instance of "object" class
So, I was playing around with Python while answering this question, and I discovered that this is not valid:
o = object()
o.attr = 'hello'
due to an AttributeError: 'object' object has no attribute 'attr'. However, with any class inherited from…

Smashery
- 57,848
- 30
- 97
- 128
95
votes
9 answers
Why design a language with unique anonymous types?
This is something that has always been bugging me as a feature of C++ lambda expressions: The type of a C++ lambda expression is unique and anonymous, I simply cannot write it down. Even if I create two lambdas that are syntactically exactly the…

cmaster - reinstate monica
- 38,891
- 9
- 62
- 106
95
votes
4 answers
Would replacing ' :: ' with ' . ' create ambiguities in C++?
In C++, the operator :: is used to access classes, functions and variables in a namespace or class.
If the language specification used . instead of :: in those cases too like when accessing instance variables/methods of an object then would that…

Jimmy R.T.
- 1,314
- 1
- 10
- 13
93
votes
4 answers
Why function template cannot be partially specialized?
I know the language specification forbids partial specialization of function template.
I would like to know the rationale why it forbids it? Are they not useful?
template void f() {} //allowed!
template<> void f

Nawaz
- 353,942
- 115
- 666
- 851
92
votes
8 answers
What are Haskell's strictness points?
We all know (or should know) that Haskell is lazy by default. Nothing is evaluated until it must be evaluated. So when must something be evaluated? There are points where Haskell must be strict. I call these "strictness points", although this…

Dan Burton
- 53,238
- 27
- 117
- 198
91
votes
6 answers
Does any other language other than JavaScript have a difference between brace start locations (same line and next line)?
Today, while I was randomly reading the JavaScript patterns O'Reilly book, I found one interesting thing (page 27 for reference).
In Javascript, in some cases, there is a difference if the brace start location is different.
function test_function1()…

Rajat Singhal
- 11,234
- 5
- 38
- 56
91
votes
6 answers
Why is there no base class in C++?
From a design point of view, why is that, in C++, there is no mother-of-all base-class, what's usually object in other languages?

salezica
- 74,081
- 25
- 105
- 166
90
votes
4 answers
Why must the last part of an Objective-C method name take an argument (when there is more than one part)?
In Objective-C, you can't declare method names where the last component doesn't take an argument. For example, the following is illegal.
-(void)take:(id)theMoney andRun;
-(void)take:(id)yourMedicine andDontComplain;
Why was Objective-C designed…

outis
- 75,655
- 22
- 151
- 221
89
votes
17 answers
Why are references not reseatable in C++
C++ references have two properties:
They always point to the same object.
They can not be 0.
Pointers are the opposite:
They can point to different objects.
They can be 0.
Why is there no "non-nullable, reseatable reference or pointer" in C++? I…

TheFogger
- 2,399
- 1
- 20
- 22
89
votes
8 answers
Why does Java have an "unreachable statement" compiler error?
I often find when debugging a program it is convenient, (although arguably bad practice) to insert a return statement inside a block of code. I might try something like this in Java ....
class Test {
public static void main(String args[]) {
…

Mike
- 58,961
- 76
- 175
- 221
88
votes
9 answers
Why does C# allow {} code blocks without a preceding statement?
Why does C# allow code blocks without a preceding statement (e.g. if, else, for, while)?
void Main()
{
{ // any sense in this?
Console.Write("foo");
}
}

Seldon
- 1,395
- 1
- 11
- 19
86
votes
4 answers
Why does Java not allow foreach on iterators (only on iterables)?
Possible Duplicate:
Why is Java's Iterator not an Iterable?
Idiomatic way to use for-each loop given an iterator?
Can we use for-each loop for iterating the objects of Iterator type?
The foreach loop are as far as I know syntax sugar added in Java…

Has QUIT--Anony-Mousse
- 76,138
- 12
- 138
- 194
86
votes
5 answers
What's the difference between __builtin__ and __builtins__?
I was coding today and noticed something. If I open a new interpreter session (IDLE) and check what's defined with the dir function I get this:
$ python
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__']
>>>…

santiagobasulto
- 11,320
- 11
- 64
- 88
86
votes
2 answers
Which classes cannot be subclassed?
Is there any rule about which built-in and standard library classes are not subclassable ("final")?
As of Python 3.3, here are a few examples:
bool
function
operator.itemgetter
slice
I found a question which deals with the implementation of…

max
- 49,282
- 56
- 208
- 355