Suggestion: new switch statement

mike vertex at gmx.at
Wed Aug 23 08:59:00 PDT 2006


Am 23.08.2006, 15:09 Uhr, schrieb Kristian <kjkilpi at gmail.com>:

> I do that also sometimes. Pressing AltGr+7 with the middle finger  
> happens, um, maybe 10-20% of the cases, at maximum, though. Pressing  
> AltGr with a right hand's thumb and 7 with the left hand's middle finger  
> does not involve lifting my right elbow. Which seems to happen when  
> using one hand only... Hey, that must be a reason why I have adopted the  
> two hand style... :)

Hehe ... I never noticed that I actually do lift my right elbow every time  
I write curly braces. Now that's interesting :-)

Writing code with a german keyboard layout is sometimes very interesting.  
Did you ever program in Turbo Pascal on DOS? Linked lists? My keyboard  
driver was beeping every 10-20 seconds when I was programming (since you  
declare a pointer with the ^ character) :-)

> Yeah, mixing the different syntaxes could make a mess. I guess compiler  
> could produce error messages in such situations. Importantly it wouldn't  
> break old code.
>
> Now this syntax will indeed fit to the overall syntax ("if() {}" <=>  
> "case() {}"). When I read my first book of C I wondered why the syntax  
> of the switch statement was different and not like this one. I guess  
> that's because it will allow you to write some complex code. But this  
> hybrid style would allow that also.

To me that syntax looks and feels like D. It would also allow some pretty  
advanced control flow through the switch, like

case (6) if (foo()) continue(7); else continue(8);

Anyway: I'm kinda glad you brought this topic up, since I'm currently  
toying aroung with designing a scripting language, and I hadn't yet  
implemented a switch statement. Now that you've brought that up, I'll toss  
the C-style switch out and implement it that way. Thanks!

-Mike

-- 
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list