Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I agree emphatically with <a href="https://stackoverflow.com/questions/411906/c-net-design-flaws/413093#413093">this post</a> (for those poo-pooing the lack of ToString, there is a debugger attribute to provide a custom format for your class).</p> <p>On top of the above list, I would also add the following reasonable requests:</p> <ol> <li>non-nullable reference types as a complement to nullable value types,</li> <li>allow overriding a struct's empty constructor,</li> <li>allow generic type constraints to specify sealed classes,</li> <li>I agree with another poster here that requested arbitrary constructor signatures when used as constraints, ie. where T : new(string), or where T : new(string, int),</li> <li>I also agree with another poster here about fixing events, both for empty event lists and in the concurrent setting (though the latter is tricky),</li> <li>operators should be defined as extension methods, and not as static methods of the class (or not just as static methods at least),</li> <li>allow static properties and methods for interfaces (Java has this, but C# does not),</li> <li>allow event initialization in object initializers (only fields and properties are currently allowed),</li> <li>why is the "object initializer" syntax only usable when creating an object? Why not make it available at any time, ie. var e = new Foo(); e { Bar = baz };</li> <li>fix quadratic enumerable behaviour,</li> <li>all collections should have immutable snapshots for iteration (ie. mutating the collection should not invalidate the iterator),</li> <li>tuples are easy to add, but an efficient closed algebraic type like "Either" is not, so I'd love some way to declare a closed algebraic type and enforce exhaustive pattern matching on it (basically first-class support for the visitor pattern, but far more efficient); so just take enums, extend them with exhaustive pattern matching support, and don't allow invalid cases,</li> <li>I'd love support for pattern matching in general, but at the very least for object type testing; I also kinda like the switch syntax proposed in another post here,</li> <li>I agree with another post that the System.IO classes, like Stream, are somewhat poorly designed; any interface that requires some implementations to throw NotSupportException is a bad design,</li> <li>IList should be much simpler than it is; in fact, this may be true for many of the concrete collection interfaces, like ICollection,</li> <li>too many methods throw exceptions, like IDictionary for instance,</li> <li>I would prefer a form of checked exceptions better than that available in Java (see the research on type and effect systems for how this can be done),</li> <li>fix various annoying corner cases in generic method overload resolution; for instance, try providing two overloaded extension methods, one that operates on reference types, and the other on nullable struct types, and see how your type inference likes that,</li> <li>provide a way to safely reflect on field and member names for interfaces like INotifyPropertyChanged, that take the field name as a string; you can do this by using an extension method that takes a lambda with a MemberExpression, ie. () => Foo, but that's not very efficient,</li> <li>allow operators in interfaces, and make all core number types implement IArithmetic; other useful shared operator interfaces are possible as well,</li> <li>make it harder to mutate object fields/properties, or at the very least, allow annotating immutable fields and make the type checker enforce it (just treat it as getter-only property fer chrissakes, it's not hard!); in fact, unify fields and properties in a more sensible way since there's no point in having both; C# 3.0's automatic properties are a first step in this direction, but they don't go far enough,</li> <li>simplify declaring constructors; I like F#'s approach, but the other post here that requires simply "new" instead of the class name is better at least,</li> </ol> <p>That's enough for now I suppose. These are all irritations I've run into in the past week. I could probably go on for hours if I really put my mind to it. C# 4.0 is already adding named, optional and default arguments, which I emphatically approve of.</p> <p>Now for one unreasonable request:</p> <ol> <li>it'd be <strong>really, really</strong> nice if C#/CLR could support type constructor polymorphism, ie. generics over generics,</li> </ol> <p>Pretty please? :-)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COWith regard to #1, every type must either have some default value, or the system must provide a means of running a constructor whenever a variable or field of a particular type is allocated. I'd prefer the latter (an offshoot of #2) but #1 could be accommodated if non-virtual methods/properties could be decorated to specify that they should be called without a null-check. This would allow things like "String" fields to behave as though they default to an empty string rather than null (since String's static "length" function could return 0 if invoked on a null string).
      singulars
    2. COWith regard to #2, it would be useful in general if structs could specify not only a constructor other than fill-with-zero, but also a copy constructor other than byte-for-byte-copy. Actually, I'd really like to see a .net-like framework which could do a good job of recognizing that entities may have value or reference semantics, and allowing value-type heap objects to be tagged mutable, shared-immutable, or uncommitted (an uncommitted value object may be mutated if its mode is first CompareExchange'd to mutable, or may be shared if its mode is first CompareExchange'd to shared).
      singulars
    3. COExcellent points! For #1, a type system annotation is the common solution, but I prefer propagating constructor constraints via type variables, like T:new(). Re:#2, good point about copy constructors, but I would be happy with more general constructors along the lines I described above. Even better would be to eliminate constructors-as-distinguished-methods entirely and simply make them static methods. This allows simpler and more general construction patterns, particularly if we allow static methods on interfaces. Constructors-as-static-methods + static-methods-in-interfaces solves #1 too.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload