Tech Off Post

Single Post Permalink

View Thread: How about some syntax sugar for IEnumerable<>?
  • User profile image

    Yggdrasil said:
    To get back to the original topic - I'm all for the proposed syntax change. When you start using LINQ a lot, passing IEnumerable<T>s back and forth, you start hating how long it is - not to write, since we have autocomplete intellisense for that, but to read. It fills up the code with useless letters. 

    I second the * syntax, though that would cause problems with unsafe code. A coworker of mine wants to just tack the plural 's' onto it, so an IEnumerable<string> would just be strings. Of course, that would mean that an IEnumerable<Bus>, for instance, would have to be correctly parsed by the compiler from Buses. And that's before we even make the compiler understand the shorthand for IEnumerable<Mouse>...

    I would prefer the IDE to auto-expand out my "var" keywords to what they really are when I give it a shortcut key - this would allow you to just write

    var myFoo = select ... <Tab> <Tab> <ShortCutKey>

    IEnumerable<ICollection<Structure<MyFoo<Dictionary<Gets<Quite<Long>, Doesnt> It>>...>> myFoo = select ...

    Actually adding keywords dilutes the language and makes it harder to read.