Sunday, February 13, 2011
Nemerle at Wikipedia.
The article about Nemerle has been removed from Wikipedia as a non-notable programming language.
Tuesday, February 1, 2011
INumeric policy.
Policies:
interface INumericPolicy<T> { T Zero(); T Add(T a, T b); ... } class All: INumericPolicy<int>, INumericPolicy<long>, ... { ... public static All P = new All(); }User's algorithms:
static class Algorithms { public static T Sum<P, T>(this P p, params T[] a) where P: INumericPolicy<T> { var r = p.Zero(); foreach(var i in a) { r = p.Add(r, i); } return r; } ... }Usage:
int i = All.P.Sum(1, 2, 3, 4, 5); long l = All.P.Sum(1L, 2, 3, 4, 5);
Monday, January 31, 2011
.NET/C# 5 wish list
- Merge WPF and Silverlight. .NET Framework and .NET Compact Framework. It would be better to have just different profiles of framework like (.NET client profile) instead of different frameworks.
- Non-nullable references
string! x = "xxx";
- Discriminated unions:
union MyUnion: Enum { case Enum.Red: RedClass; case Enum.Green: GreenClass; ... }
- INumeric interface for standard numeric types.
struct UInt32: INumeric<UInt32> { ... }
- Fixed size arrays
byte[10] x;
- Operator extensions (syntax sugar):
public static class Extensions { public static T operator+ <T>(T a, T b) where T: INumeric<T> ... }
- Polymorphic up cast:
class A: B { ... } ... new A() up B
Update: No needs any more. Solution:
public static class Extension { public static T UpCast<T>(T derived) { return derived; } }
Example:
new B().UpCast<A>()
- Force use 'using' keyword for some classes.
using class My: IDisposable { .... } ... // Ok. using(var my = new My()) { } // Compilation error. { var my = new My(); } // Ok. return new My();
- Units of measurements. As in F# http://msdn.microsoft.com/en-us/library/dd233243.aspx.
- Named code blocks.
code Block { foreach(var x in M) { foreach(var y in x) { if(y) break Block; } } }
- A reference to an anonymous delegate inside the delegate.
Control.Selected += (s, e) => { ... Control.Selected -= this function; }
Subscribe to:
Posts (Atom)