I'm wondering if any other C# developers would find it an improvement to have a complier directive for CSC to make whitespace significant ala Haskell or Python where the kinds of whitespace creates code blocks.
While this would certainly be a massive departure from c-style languages, it seems to me that since C# is ultimately being compiled down to IL (which would still have the curly braces and semicolons), it really is just a parsing trick the compiler can handle either way (i.e. it can either deal with significant whitespaces or not). Since curlies and semicolons are often a barrier to entry to C# & they are really only parsing helpers (they don't in themselves impart meaning to your code) they could be removed ala Haskell/Python.
F# handles with the the #light complier directive which you can read about here: http://blogs.msdn.com/dsyme/archive/2006/08/24/715626.aspx
I'd like to see the same thing in C#: a #SigSpace or somesuch directive that would direct CSC to treat the source like a Haskell file in terms of whitespace (just as an example).
standard C#:
public void WhiteSpaceSig()
{
List<string> names = new List<string>();
List<string> colors = new List<string>();
foreach (string name in names)
{
foreach (string color in colors)
{
// bla bla bla
}
}
}
significant whitespace:
#SigSpace
public void WhiteSpaceSig()
List<string> names = new List<string>()
List<string> colors = new List<string>()
foreach (string name in names)
foreach (string color in colors)
// bla bla bla
I'm not saying that I want this in C#, but I am interested in what the tradeoffs are. My guess is that most C# developers have gotten so used to the syntax that they won't be able to see how artificial it is (though it may in the end make the code easier to read).