Switch versus if/then/else ( was: Main menu puzzle, Klaus)

Rob Cozens rcozens at pon.net
Mon Feb 20 10:13:01 CST 2006


Judy, et al:

> If-Thens are readily comprehensible by non/novice-programmers.
>

And by extension, switch statements are not. [?]

When I gave you this point in an earlier post, I was really conceding 
that the syntax of a switch statement does not flow in the same 
English-like fashion of "ifs" in xTalk.

Maybe I've been at it too long to see the forest for the trees; but I 
truly don't see what is so hard to comprehend about the switch concept. 
  One identifies  a switch value and specifies different logic paths to 
follow depending on the value of the switch.

	on menuPick thePick
		switch thePick
			case "Cut"
				...
				break
			case "Copy"
				...
				break
			case "Paste"
				...
				break
			[etc.]
			default
				answer warning quote&thePick&quote&&"is not supported!"
		end switch
	end menuPick

It can be explained in terms of if/then/else--which you find easily 
comprehended--; so when it's explained in that context it should be 
readily understood....no?

Again, I'll grant you that there is more to switches than that simple 
example shows; but the basic concept is not that difficult to 
understand or explain (to me; but I have to defer to your classroom 
experience, as unintuitive as it is to moi).

Rob Cozens
CCW, Serendipity Software Company

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)




More information about the use-livecode mailing list