Questions tagged [language-specifications]
126 questions
293
votes
4 answers
Is False == 0 and True == 1 an implementation detail or is it guaranteed by the language?
Is it guaranteed that False == 0 and True == 1, in Python (assuming that they are not reassigned by the user)? For instance, is it in any way guaranteed that the following code will always produce the same results, whatever the version of Python…

Eric O. Lebigot
- 91,433
- 48
- 218
- 260
273
votes
5 answers
C# short/long/int literal format?
In C/C#/etc. you can tell the compiler that a literal number is not what it appears to be (ie., float instead of double, unsigned long instead of int):
var d = 1.0; // double
var f = 1.0f; // float
var u = 1UL; // unsigned long
etc.
Could someone…

3Dave
- 28,657
- 18
- 88
- 151
139
votes
13 answers
Can you add new statements to Python's syntax?
Can you add new statements (like print, raise, with) to Python's syntax?
Say, to allow..
mystatement "Something"
Or,
new_if True:
print "example"
Not so much if you should, but rather if it's possible (short of modifying the python…

dbr
- 165,801
- 69
- 278
- 343
85
votes
3 answers
Where Can I Find the C# Language Specification 6.0?
I know where to find the C# 5 Language Specification but I cannot find the C# 6 Language Specification anywhere.
Where is the C# 6 Language Specification?

Alex Booker
- 10,487
- 1
- 24
- 34
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
- 65,159
- 33
- 165
- 230
56
votes
4 answers
Is the shortcircuit behaviour of Python's any/all explicit?
Prompted by the discussion here
The docs suggest some equivalent code for the behaviour of all and any
Should the behaviour of the equivalent code be considered part of the definition, or can an implementation implement them in a non-shortcircuit…

John La Rooy
- 295,403
- 53
- 369
- 502
54
votes
5 answers
Importing classes and namespaces in PHP: What difference does a leading backslash make?
What's the difference between those two:
use Exception;
use \Exception;
Or those:
use Foo\Bar;
use \Foo\Bar;
The manual says:
Note that for namespaced names (fully
qualified namespace names containing
namespace separator, such as Foo\Bar
as…

NikiC
- 100,734
- 37
- 191
- 225
38
votes
2 answers
Where can I find the C# 5 language specification?
C# 5.0 is out now since August 2012. Where can I find the specification? They've stopped doing ECMA specs, but how about MSDN?

Mishax
- 4,442
- 5
- 39
- 63
30
votes
2 answers
Inconsistent "possible lossy conversion from int to byte" compile-time error
Examine the following code snippets:
Snippet #1
int a=20;
int b=30;
byte c= (a>b)? 20:30;
Error:
incompatible types: possible lossy conversion from int to byte
byte c= (a>b)? 20:30;
Snippet #2
int a=20;
int b=30;
byte h1=70;
byte c= (a>b)?…

Jay Patel
- 505
- 6
- 10
29
votes
5 answers
Why does C# not allow generic properties?
I was wondering why I can not have generic property in non-generic class the way I can have generic methods. I.e.:
public interface TestClass
{
IEnumerable GetAllBy(); //this works
IEnumerable All { get; } //this does not…

Sunny Milenov
- 21,990
- 6
- 80
- 106
25
votes
5 answers
Where can I get Java 8 language specification?
Specification for Java 7 is available on the Oracle site, but I can't find Java 8 specification anywhere, although downloads of beta versions of Java 8 are available on the internet.
Do you have an idea: is it already written and where can it be…

iirekm
- 8,890
- 5
- 36
- 46
23
votes
3 answers
Why does C# define two different uses for `using`?
More a question out of curiosity than anything, but why does C# define two different "purposes" for the keyword using? On one hand, it's a directive...
used to create an alias for a
namespace or to import types defined
in other…

David Hoerster
- 28,421
- 8
- 67
- 102
23
votes
1 answer
Why does adding ".map(a -> a)" allow this to compile?
This is related to my answer to "stream reduction incompatible types". I don't know why what I suggested works, and Holger rightly pressed me on this. But even he doesn't seem to have a clear explanation for why it works. So, let's ask it as its own…

Andy Turner
- 137,514
- 11
- 162
- 243
23
votes
2 answers
How is foreach implemented in C#?
How exactly is foreach implemented in C#?
I imagine a part of it looking like:
var enumerator = TInput.GetEnumerator();
while(enumerator.MoveNext())
{
// do some stuff here
}
However I'm unsure what's really going on. What methodology is used for…

Jamie Dixon
- 53,019
- 19
- 125
- 162
21
votes
5 answers
What exactly is the HTML5 tag and what is the browser support
I've read the HTML5 spec for and found the information on this element very vague.
I've tried it out and found that it is not working in Chrome (latest version) and it is working on Safari (even older ones), sorry no FF (don't shoot me…

Trufa
- 39,971
- 43
- 126
- 190