Re: SWITCH question
- Posted by jessedavis Dec 28, 2017
- 2311 views
Are there currently any problems with switch() other than the outlier mentioned above?
I've been using it for a long time with no problem, but I have never had a need to use it directly with C_HANDLE, C_POINTER, etc., since in order to save a lot of typing, I generally assign a shorter alias for each: e.g. constant P = C_POINTER, H = C_HANDLE, etc.
As shown in the tests above, this works properly.
I stood before this forum and vowed never to use switch again. This said, it is nice to have a working switch as it is much easier than writing the equivalent with if, else, elsif, etc. and the code is easier to read and understand. I spent considerable time working on this problem (see my posts of a year ago (or so)). The conclusion I came to was pointers were not being correctly handled. I proved that the values of CONSTANTS were being changed by the switch routine. This leads to erroneous outcomes and machine level faults. I am not a capable enough programmer to fix this. It would be nice if someone would take the time to examine the problem and fix it.
regards,
jd