Created
December 4, 2013 16:15
-
-
Save pbrewczynski/7790338 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| → bluesm joined (uid13438@gateway/web/irccloud.com/x-vwzagpplvfbnrrfz) | |
| 17:06:39 Channel mode is +Ccgnt | |
| 17:06:48 ⇐ eulerphi quit ([email protected]) Ping timeout: 252 seconds | |
| 17:06:55 <bluesm> I know my question could be vague but I will ask anyway. | |
| 17:07:17 <bluesm> Does the "Switch" from enumerable value, will compare and then "jump" or just jump ? It would be not to compare... but just make array with pointers to jump [firstpointer, second pointer, third pointer] and value "0" would select "first pointer" and jump to the first pointer ? | |
| 17:07:39 ⇐ haxxpop quit ([email protected]) Quit: Konversation terminated! | |
| 17:07:45 <bluesm> Normal switch compares the given value, with other values... But if you have say "3" states. - 0 1 2 - . i could instead of comparing, it could go array of pointers get "n'th" (0 , 1 , 2 in our case) value in this array. And execute something at give pointer. | |
| 17:08:46 <bluesm> I know it could depend on the higher programming language. | |
| 17:08:54 <GeDaMo> bluesm: are you asking about the implementation of C's switch ... case? | |
| 17:09:44 → sbahra and DevilFish joined | |
| 17:10:13 <bluesm> GeDaMo: I generally how switch "from enumerable" is implemented in all language. But ok C is ok... since is close to Assembly. | |
| 17:10:36 <Jester01> depends on the compiler and the circumstances | |
| 17:11:12 <Jester01> it may be using a jump table if that seems like a good idea :) | |
| 17:11:49 <bluesm> Jester01: But enumerable... should always be done this way.... Since it have (n states) from 0 to n... So it is nice to move in memory find appropriate pointer, and go to this pointer... | |
| 17:11:58 <DevilFish> It'd be nice if you could hint implementation details to compilers. | |
| 17:12:10 <Jester01> assuming your switch uses all the values | |
| 17:12:38 <bluesm> DevilFish: So you suggest I have nice idea that could be not Yet implemented ? | |
| 17:13:03 <Jester01> if you want to "hint" to use a jump table, guess what ... you CAN use a jump table yourself :) | |
| New messages | |
| 17:13:30 <bluesm> DevilFish: I suspect it is done already... | |
| 17:13:30 <GeDaMo> http://blog.regehr.org/archives/320#example7 | |
| 17:13:32 <DevilFish> That takes work. I like compiler magic without the effort~ | |
| 17:13:45 <Jester01> yeah. so, leave it to the compiler. | |
| 17:13:58 <Jester01> it will use a jump table on its own if that seems appropriate. | |
| 17:14:06 <DevilFish> bluesm, I just joined, so I don't know what problem you're having. | |
| 17:14:10 <bluesm> Jester01: No in every programming language you can have table of pointers that point to the "function"... | |
| 17:15:04 <bluesm> DevilFish: I have no problem. I just ask about nice thing that could be (already) implemented in the compilers. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment