I'm playing around with trying to make array math in C# as easy and concise as in Matlab, and (besides array operators) the biggest language "mismatch" is in indexers, ranges, etc. In Matlab, I can easily get a subarray of A, such as A[0:5:255]
As a user of a fluent interface DSL in C#, would you ever put up with unconventional use of indexers? Like:
A[Get.Range[0,5,255]]
...where Range is actually a static readonly field holding an instance of class Range
public class Get<br> {<br> public static readonly Range Range = new Range();<br> public static readonly Size Size = new Size();<br> }<br><br> public class Range<br> {<br> public Range this[int from, int to] { get { return new Range(from, 1, to); } }<br> public Range this[int from, int every, int to] { get { return new Range(from, every, to); } }<br><br> private Range(int start, int every, int stop) { Start = start; Every = every; Stop = stop; }<br> private Range(int start, int stop) : this(start, 1, stop) { }<br> internal Range() { } Obviously the following would be more C-sharpy:
A[new Range(0,5,255)]
But, isn't it OK to stray a bit as long as there's a consistent convention in the DSL?