[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Switch/Case statements revisited
- From: "Tim Kelly" <gtkelly@...>
- Date: Wed, 7 Nov 2007 17:09:52 +0100 (CET)
I have done a lot of programming with an integrated application/database
called 4D (http://www.4d.com). It has a very useful variation on case
statements:
Case of
:(a = b)
b = b+1
:(CheckValidInput(c))
a = a+1
else
a = 0
end case
The comparisons are independent of a specific variable, and as shown by
the second example, statements within the comparison are evaluated. This
is extremely useful in handling multiple independent conditions (state
machines, priorities, pre-requisites). The (very minor) drawback is that
there is no fallthrough/leap ahead feature, so each comparison gets
evaluated until one comes back true. In a programming language like C I
can understand the need to have a fixed set of comparisons, but in an
interpreted language like Lua and 4D, I believe having extended
flexibility for comparisons has greater value than adhering to various
programming philosophies that argue counter to it.
tim
Gregory T. (tim) Kelly
Owner
Dialectronics.com
"Anything war can do, peace can do better." -- Bishop Desmond Tutu