On 8/3/2013 1:06 PM, JS wrote:
On Saturday, 3 August 2013 at 19:22:53 UTC, Walter Bright wrote:
On 8/3/2013 12:00 PM, JS wrote:
What I really don't get it is why people think that just because they won't use
such a feature then it must be useless to everyone else.
You could provide supporting evidence by examining every use of switch in the
dmd, phobos, and druntime source code, and see what percentage of those would
benefit from your proposal.
This is illogical. The code wasn't written with such a semantic in mind so it
would require me to rewrite the library to see how useful it truly is.
There are two kinds of semantic language improvements:
1. one that is transformative to programming style, i.e. you'd write your
program in a fundamentally different way, like OOP.
2. one that is automating an existing pattern, which is finding a recurring
pattern in code and providing syntactic sugar for it. The foreach loop is in
this category.
Your proposal looks to me like (2), in fact, you wrote:
Since the transformation is rather trivial
which supports that categorization.
So, to make automating an existing pattern worthwhile, there ought to be a
significant percentage of code exhibiting that existing pattern.
For example, bearopile listed:
enum mysize(T) = T.sizeof;
which does automate a commonly recurring pattern.
You see how difficult is for me to "sell" it.
Yes, and it should be difficult to sell a new language feature.
For example, suppose what I am suggesting has zero cost to implement and
maintain...
Would you allow it in D?
There's no such thing - and certainly your proposal is not. Any syntactic change
requires an ongoing cost in:
1. implementation
2. maintenance
3. testing
4. documentation
5. users have to learn it
6. books and tutorials about D have to discuss it
Repeat steps 1..6 for every tool that deals with D source code.
Therefore, there needs to be an advantage to it that outweigh all of that. It's
a high bar. This is true for every language out there, and if you invent your
own language, you'll quickly start applying that criteria as well.