Wednesday, June 23, 2004
What will I code at the moment when I'd obtain my copy of new C#? First I'll try to use templates and anonymous delegates at their full potential. First I'd like to have a class
Please, note that the delegate body has been declared as bool. The purpose is to allow complete mirroring of foreach statement.
break statement is meaningless in this case unless it was equivalent to return false. Reciprocally contiunue would be equivalent to return true. While the example was not very practical, it's illustrative. Certainly the anonymous delegate should return true by default.
Another feature would be a statement for instantiation of a template. Just like in C++
I work on a class library which requires this feature.
Next I'd like to be able to restrict the use the template on ordered and additive types only:
Next a variation of Each method
Or this could be declared as
Then DiscontinuousRange<Type T, T step> could be declared to provide Each method with default step etc.
Let's return to IAdditive and IComparable. It would be good if the classification was a little bit complicated. For example, let's declare IOrdered. Then IContinuous:IOrdered, IDiscontinuous:IOrdered, and IAlternative:IOrdered. Finally declare Int32 as IDiscontinuous, Double as IContinuous, Boolean as IAlternative. This will provide an opportunity to define
The Range class is especially useful in defining ranges of continuous data such as DateTime.
One more piece of sugar: