Re: The fate of Euphoria
On Mon, 8 Nov 2004 19:35:50 -0600, Kat <gertie at visionsix.com> wrote:
> > I tend to somewhat disagree with this, CASE is a glorified If...ElseIf
> > statement. You are not really going anywhere, you are saying in the CASE
> > where
> > this is equal to this, then do this code. Not goto this other place.
>
> Yes it does. After hitting the first valid case line, it goto's the endcase
> line.
> Same with the elsif, once a line (or block) is executed, no more of the
> if..elsif..end is tested, it does a goto the end if.
Kat: In C/C++ and Java, case does this:
char all_ones(int exp)
{
int result = 0;
switch (a)
{
case 8: result += 128;
case 7: result += 64
case 6: result += 32;
case 5: result += 16;
case 4: result += 8;
case 3: result += 4;
case 2: result += 2;
case 1: result += 1;
break;
default; //Do nothing, result is zero
}
return result;
}
This function returns an 8-bit number that is all ones. (Yes, I know
it could be done with "return power(2,exp+1)-1", this is just an
example.)
It doesn't exit out of the switch statement until you call break. If
switch was implemented in Euphoria, I think it would have to do things
this way, as C/C++ and Java both do things like this, and most
programmers use one of the three languages.
--
MrTrick
|
Not Categorized, Please Help
|
|