Questions tagged [language-features]

A language feature is a distinct aspect of a programming language, such as binding rules, lexical design, or facets of the type system.

613 questions
71
votes
7 answers

Python: How to pass more than one argument to the property getter?

Consider the following example: class A: @property def x(self): return 5 So, of course calling the a = A(); a.x will return 5 But imagine that you want to be able to modify the property x. This way, for example: class A: @property …
Rizo
  • 2,623
  • 5
  • 29
  • 46
69
votes
12 answers

Will a future version of .NET support tuples in C#?

.Net 3.5 doesn't support tuples. Too bad, But not sure whether the future version of .net will support tuples or not?
Graviton
  • 76,900
  • 138
  • 399
  • 575
66
votes
4 answers

Why does Java permit escaped unicode characters in the source code?

I recently learned that Unicode is permitted within Java source code not only as Unicode characters (eg. double π = Math.PI; ) but also as escaped sequences (eg. double \u03C0 = Math.PI; ). The first variant makes sense to me - it allows programmers…
Zaven Nahapetyan
  • 1,239
  • 1
  • 10
  • 15
64
votes
4 answers

What's the difference between a hash and hash reference in Perl?

I would like to properly understand hashes in Perl. I've had to use Perl intermittently for quite some time and mostly whenever I need to do it, it's mostly related to text processing. And everytime, I have to deal with hashes, it gets messed up. I…
user855
  • 16,878
  • 34
  • 86
  • 143
63
votes
5 answers

Double dispatch in C#?

I have heard/read the term but don't quite understand what it means. When should I use this technique and how would I use it? Can anyone provide a good code sample?
Oded
  • 463,167
  • 92
  • 837
  • 979
62
votes
1 answer

Problem understanding C# type inference as described in the language specification

The C# language specification describes type inference in Section §7.5.2. There is a detail in it that I don’t understand. Consider the following case: // declaration void Method(T obj, Func func); // call Method("obj", s => (object)…
Timwi
  • 61,190
  • 29
  • 155
  • 224
61
votes
8 answers

Javascript as a functional language

I am looking get to grips with functional programming concepts. I've used Javascript for many years for client side scripting in web applications and apart from using prototypes it was all simple DOM manipulation, input validation etc. Of late, I…
Ash
  • 57,515
  • 31
  • 146
  • 168
58
votes
9 answers

Why isn't there an endianness modifier in C++ like there is for signedness?

(I guess this question could apply to many typed languages, but I chose to use C++ as an example.) Why is there no way to just write: struct foo { little int x; // little-endian big long int y; // big-endian short z; // native…
Lena Schimmel
  • 6,934
  • 5
  • 41
  • 56
55
votes
4 answers

Python type() or __class__, == or is

I want to test whether an object is an instance of a class, and only this class (no subclasses). I could do it either with: obj.__class__ == Foo obj.__class__ is Foo type(obj) == Foo type(obj) is Foo Are there reasons to choose one over another?…
mgibsonbr
  • 20,967
  • 7
  • 62
  • 102
47
votes
6 answers

Methods in Ruby: objects or not?

Inspired by this discussion, after some googling I wasn't able to find an answer to a pretty simple question regarding methods in Ruby: are methods objects or not? There are different opinions here and there, and I would really like to hear, let's…
Mladen Jablanović
  • 41,202
  • 10
  • 87
  • 110
46
votes
7 answers

What is the purpose of long, double, byte, char in Java?

So I'm learning java, and I have a question. It seems that the types int, boolean and string will be good for just about everything I'll ever need in terms of variables, except perhaps float could be used when decimal numbers are needed in a…
Click Upvote
  • 235,452
  • 251
  • 553
  • 736
44
votes
2 answers

Equivalent of Class Loaders in .NET

Does anyone know if it possible to define the equivalent of a "java custom class loader" in .NET? To give a little background: I am in the process of developing a new programming language that targets the CLR, called "Liberty". One of the features…
42
votes
1 answer

Why doesn't Java varargs support collections?

In my Java code I often use the very handy method(Class... args) varargs. As far as I know, they allow you to pass any amount of Class objects or an array of Class[]. Since I also often use the Java collection classes, I am frustrated by the lack of…
tb189
  • 1,842
  • 3
  • 20
  • 34
41
votes
19 answers

Have you ever restricted yourself to using a subset of language features?

Have you ever restricted yourself to using a subset of language features, and more importantly, why? I'm curious to find out who choose to use only certain language features and avoid others in order to win big in areas such as, but not limited to,…
Jonathon Watney
  • 15,080
  • 8
  • 34
  • 40
40
votes
6 answers

C# method call with parameter name and colon

I've begun to notice at times when I'm making method calls in C# that the names of the parameters for the method I'm calling will show up in the intellisense list appended with a colon, and that I can then format the method call…
Zann Anderson
  • 4,408
  • 9
  • 32
  • 55
1 2
3
40 41