On Jun 1, 11 05:37, Andrej Mitrovic wrote:
On 5/31/11, Nick Sabalausky<a@a.a>  wrote:
"eles"<e...@eles.com>  wrote in message news:is3ihf$qnu$1...@digitalmars.com...
== Quote from Ali Çehreli (acehr...@yahoo.com)'s article
On 05/31/2011 08:10 AM, eles wrote:
  >  I know no other examples where open-right limits are used.
The C++ standard library uses open-right with its pairs of
iterators.
The second iterator "points" at one beyond the last element of the
range.
Ali

C'mon, if C++ is such a good standard, then D would have never
appeared. Why not dropping D completely and go to C++ then?

The fact that C++ uses it that way does not making it good for us.

D choose slices, not iterators. Maybe we should remind why it did it
in the first place.

Now, we are taking the "enemy" (well, is a joke) as a reference in
the matter?



First you complain about D doing it differently from other popular
languages. Then when you're given a counterexample, you start complaining
that D *isn't* doing it differently??? You're really just trolling, aren't
you?


Matlab programmers, Java programmers, they all want D to act their way.

As for switch statements (and this is getting offtopic), there are
cases where fallback is nice to have..


It's already off-topic at the time the close vs open range debate has started :)

final switch (param)
{
     case FILE_NEW:
     case FILE_OPEN:
     case FILE_SAVE:
     case FILE_SAVE_AS:
     case EDIT_UNDO:

In D you'd write it as

       case FILE_NEW, FILE_OPEN, FILE_SAVE, FILE_SAVE_AS, EDIT_UNDO:

this doesn't need fall-through.

         throw new Exception("unimplemented!");  // or there would be
one method that handles these cases
     case EDIT_CUT:
         handleCut();
         break;
     case EDIT_COPY:
         handleCopy();
         break;
     case EDIT_PASTE:
         handlePaste();
         break;
     case EDIT_CLEAR:
         handleClear();
         break;
}
return 0;

If you didn't have fallback, you would probably have to add some kind
of new statement like "goto next" or "fallback" on each of those
cases.

It already exists. It is called#

           goto case;


On the other hand, having to add break everywhere is a pain too. So
maybe the change would benefit overall.


To avoid surprising C users, I don't think you can't avoid having to add break everywhere. But it's still good to disallow implicit fall-through. I think the C# behavior* is good enough.

The switch statement is a weird construct. It's as if suddenly you're
coding in Python with no curly braces. :)

*: http://msdn.microsoft.com/en-us/library/06tc147t(v=VS.100).aspx
#: http://d-programming-language.org/statement.html#GotoStatement

Reply via email to