Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #13  
Old 05-01-2009, 09:48 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by Gambet View Post
Not true, Java's switch() does not only allow ints (it also allows char, byte, and short types), and for that matter, switch() works the same in just about every other popular language (such as C++ which was used largely in making Graal).
All the languages that do switch statements and only allow you switch on integral types do that on account of having copied the syntax pretty much verbatim from C.

D lets you switch on strings, perl does not let you switch at all unless you write your own switchiness, ruby lets you switch on pretty much goddamn anything that defines an operator for matching a switch case. In Haskell and Nemerle, a switch-like structure is the basic low-level control structure and works for everything as well.

Quote:
Regardless, though, I still feel that it was quite unnecessary in this case.
I think it is purely a matter of style, here. Checking a variable against a sequence of values looks neater if you do not have to repeat the "variable ==" over and over, but all the break;s are pretty annoying too, I guess.

Quote:
I agree that it isn't so important for this example, but when you're dealing with large scripts (such as the code for Windows that is well past millions of lines), it is quite important to shorten the number of lines as much as possible. Just a general tip.
No, generally you want to make sure your code is as readable and maintainable as possible. The number of lines should only enter it a whole lot after that.
Reply With Quote
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 06:34 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.