language-specifications

Question regarding implicit conversions in the C# language specification

和自甴很熟 提交于 2019-12-03 06:01:49
Section 6.1 Implicit conversions defines an identity conversion thusly: An identity conversion converts from any type to the same type. This conversion exists such that an entity that already has a required type can be said to be convertible to that type. Now, what is the purpose of sentences such as these? (In §6.1.6 Implicit reference conversions) The implicit reference conversions are: [...] From any reference-type to a reference-type T if it has an implicit identity or reference conversion to a reference-type T 0 and T 0 has an identity conversion to T . and: (In §6.1.7 Boxing conversions)

Where is it specified whether Unicode identifiers should be allowed in a Haskell implementation?

扶醉桌前 提交于 2019-12-01 03:28:07
I wanted to write some educational code in Haskell with Unicode characters (non-Latin) in the identifiers. (So that the identifiers look nice and natural for speakers of a natural language other than English which is not using the Latin characters in its writing.) So, I set out for finding an appropriate Haskell implementation that would allow this. But where is this feature specified in the language specification? How would I refer to this feature when looking for a conforming implementation? (And which Haskell implemenations are known to actually support Unicode identifiers?) It turned out

Operator '==' can't be applied to type T?

倾然丶 夕夏残阳落幕 提交于 2019-12-01 02:54:01
I thought this method was valid but I was wrong: static void Equals<T>(T x, T y) { return x == y; //operator == can't be applied to type T } After reading the specifiation (§7.2.4 in v3.0 and §7.3.4 in v4.0): 7.2.4 Binary operator overload resolution An operation of the form x op y, where op is an overloadable binary operator, x is an expression of type X, and y is an expression of type Y, is processed as follows: The set of candidate user-defined operators provided by X and Y for the operation operator op(x, y) is determined. The set consists of the union of the candidate operators provided

Why is it not allowed in Java to overload Foo(Object…) with Foo(Object[])?

删除回忆录丶 提交于 2019-12-01 02:47:52
I was wondering why it is not allowed in Java to overload Foo(Object[] args) with Foo(Object... args) , though they are used in a different way? Foo(Object[] args){} is used like: Foo(new Object[]{new Object(), new Object()}); while the other form: Foo(Object... args){} is used like: Foo(new Object(), new Object()); Is there any reason behind this? This 15.12.2.5 Choosing the Most Specific Method talk about this, but its quite complex. e.g. Choosing between Foo(Number... ints) and Foo(Integer... ints) In the interests of backward compatibility, these are effectively the same thing. public Foo

Questions about Structs

自闭症网瘾萝莉.ら 提交于 2019-11-30 20:12:47
MSDN says that a class that would be 16 bytes or less would be better handled as a struct [citation] . Why is that? Does that mean that if a struct is over 16 bytes it's less efficient than a class or is it the same? How do you determine if your class is under 16 bytes? What restricts a struct from acting like a class? (besides disallowing parameterless constructors) There are a couple different answers to this question, and it is a bit subjective, but some reasons I can think of are: Structs are value-type, classes are reference type. If you're using 16 bytes for total storage, it's probably

Questions about Structs

时光怂恿深爱的人放手 提交于 2019-11-30 04:41:26
问题 MSDN says that a class that would be 16 bytes or less would be better handled as a struct [citation]. Why is that? Does that mean that if a struct is over 16 bytes it's less efficient than a class or is it the same? How do you determine if your class is under 16 bytes? What restricts a struct from acting like a class? (besides disallowing parameterless constructors) 回答1: There are a couple different answers to this question, and it is a bit subjective, but some reasons I can think of are:

XSD doesn't allow me to have unbounded inside all indicator

霸气de小男生 提交于 2019-11-29 03:25:40
I'm trying to make unordered list of variables in var1 occurs twice and var2 occurs infinite times (Use case in my project is different). The element does not allow me to use maxOccurs. Is there any work around for what I'm trying to do? <?xml version="1.0" encoding="ISO-8859-1"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="testcomment"> <xs:complexType> <xs:all> <xs:element name="var1" type="xs:string" maxOccurs="2" /> <xs:element name="var2" type="xs:integer" maxOccurs="unbounded" /> </xs:all> </xs:complexType> </xs:element> </xs:schema> What you're trying to do

Why does adding “.map(a -> a)” allow this to compile?

我与影子孤独终老i 提交于 2019-11-28 19:17:38
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 question: The following code does not compile in javac (for the links to ideone below, this is sun-jdk-1.8.0_51 , per http://ideone.com/faq ): public <T> Object with(Stream<Predicate<? super T>> predicates) { return predicates.reduce(Predicate::or); } And rightly so: or-ing together two predicates from this stream is like writing: Predicate<?

What exactly is the HTML5 <command> tag and what is the browser support

元气小坏坏 提交于 2019-11-28 10:45:27
I've read the HTML5 spec for <command> 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 please) - Mac only test. I can't understand what is the use of this element or even if I'm using it correctly. I thank you in advance for any clarification about it! It works on Firefox 3.6.13 from Windows by the way. The command element is meant to encapsulate something that you can do. It can be rendered within a menu (since a menu presents items you

Where can I find the C# 5 language specification?

a 夏天 提交于 2019-11-28 05:16:00
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? Excommunicated It was originally unavailable online but since June 2013 it is available for download from Microsoft . If you have Visual Studio 2012 installed, you will find specification somewhere there: c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC#\Specifications\1033\CSharp Language Specification.docx similar with VS2013: c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC#\Specifications\1033\CSharp Language Specification.docx VS2015: c:\Program Files