language-specifications


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

♀尐吖头ヾ 提交于 2019-12-30 08:14:39
问题 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

How to efficiently ensure a decimal value has at least N decimal places

£可爱£侵袭症+ 提交于 2019-12-23 12:27:46
问题 I want to efficiently ensure a decimal value has at least N (=3 in the example below) places, prior to doing arithmetic operations. Obviouly I could format with "0.000######....#" then parse, but it's relatively inefficient and I'm looking for a solution that avoids converting to/from a string. I've tried the following solution: decimal d = 1.23M; d = d + 1.000M - 1; Console.WriteLine("Result = " + d.ToString()); // 1.230 which seems to work for all values <= Decimal.MaxValue - 1 when

Why doesn't an array access expression of a null array reference throw a NullPointerException?

混江龙づ霸主 提交于 2019-12-22 06:36:07
问题 Consider the following code: int[] r = null; r[0] = 1 % 0; I would have expected this to throw a NullPointerException : according to JLS Sec 15.7.1: The left-hand operand of a binary operator appears to be fully evaluated before any part of the right-hand operand is evaluated. = is a binary operator (shown in JLS Sec 15.2 - JLS Sec 15.26 describes assignment operators), and fully-evaluating the left-hand operand will result in a NullPointerException . However, an ArithmeticException is thrown

How to refer to a class when both simple and fully-qualified names clash

依然范特西╮ 提交于 2019-12-21 07:28:50
问题 Consider the following pathological example: class Ideone { static class ArrayList<T> { ArrayList() { System.out.println("!!"); } } static class java { static class util { static class ArrayList<T> { ArrayList() { System.out.println("Here"); } } } } public static void main(String[] args) { new ArrayList<>(); new java.util.ArrayList<>(); // Can I refer to the "usual" java.util.ArrayList? } } The two instances created in the constructor are of the nested classes. But how might I refer to the

Question regarding implicit conversions in the C# language specification

孤街浪徒 提交于 2019-12-20 19:25:10
问题 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

Question regarding implicit conversions in the C# language specification

余生颓废 提交于 2019-12-20 19:24:03
问题 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

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

别来无恙 提交于 2019-12-19 05:17:59
问题 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

Where can I find the C# 5 language specification?

纵然是瞬间 提交于 2019-12-17 17:48:06
问题 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? 回答1: It was originally unavailable online but since June 2013 it is available for download from Microsoft. 回答2: 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

Where Can I Find the C# Language Specification 6.0? [closed]

强颜欢笑 提交于 2019-12-17 17:33:54
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . 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? 回答1: At time of writing (May 2016) Microsoft hasn't yet finished updating the spec for C#6. In the meantime, I put up Microsoft's latest current draft of the

Why does C# not allow generic properties?

拈花ヽ惹草 提交于 2019-12-17 10:59:11
问题 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<T> GetAllBy<T>(); //this works IEnumerable<T> All<T> { get; } //this does not work } I read @Jon Skeet's answer, but it's just a statement, which most probably is somewhere in the specifications. My question is why actually it is that way? Was kind of problems were avoided with this limitation? 回答1: Technically, the CLR supports only

工具导航Map