Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!MITCH.ENG.SUN.COM!wmb From: wmb@MITCH.ENG.SUN.COM (Mitch Bradley) Newsgroups: comp.lang.forth Subject: Re: BASIS 14... comments Message-ID: <9012031438.AA22175@ucbvax.Berkeley.EDU> Date: 3 Dec 90 07:28:26 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Mitch Bradley Organization: The Internet Lines: 109 > But what is the stack behavior [of the CASE construct] ? > I see now that there is no OTHERWISE This is the "classic" Eaker case statement as described in Forth Dimensions volume 1. It's the winner of the "Great Forth Dimensions Case Contest". CASE ( selector -- selector ) OF ( selector match-value -- ) if match OF ( selector match-value -- selector ) otherwise ENDOF ( -- ) if preceding OF matched ENDOF ( -- selector ) otherwise ENDCASE ( selector -- ) The "otherwise" case is implicit. Example: : CARDNAME ( n -- ) CASE 1 OF ." Ace" ENDOF 2 OF ." Deuce" ENDOF 3 OF ." Trey" ENDOF 11 OF ." Jack" ENDOF 12 OF ." Queen" ENDOF 13 OF ." King" ENDOF ( n ) DUP . ( n ) ENDCASE ; The "default" code ( "dup ." in this example) is optional. Note that the default code must take care to leave something on the stack for ENDCASE to drop. This case statement has its faults, but it has its virtues too. It's a good tradeoff. I use it a lot. Sometimes a "jump table" case statement is better, sometimes not. Eaker's case statement definitely has a lot of common practice behind it. > You didn't understand my point. See, let's say that I have an ANS compatible > Forth, with some extension wordsets. One day, I find in a BBS a very useful > program (routine...) written for ANS Forth Standard. I download it and then: > > 1) I just run it. It will tell me if it can run on my system. > 2) Analize the code, so I can see if I can run it on my system. > > Providing ONLY and ALSO is easier than ORDER.... I'm sorry, I'm still not sure that I understand. Are we perhaps talking about a different meaning of ORDER ? ANS ORDER displays the search order for the programmer's benefit. It's a debugging tool. I don't find it particularly difficult to implement. I think I must be missing something. > Yeah. What are the cons against MULTI, SINGLE, PAUSE, WAKE, SLEEP > cooperative multitasking? I know that someone may need time-slice, > but we could provide two Multitasking wordsets... Different needs... I anticipate that the discussion will proceed as follows: 1) The desire for a wordset that can encompass both cooperative and preemptive multitasking will be aired. 2) Technical arguments will be voiced to the effect that this is impractical. These arguments are likely to be compelling. 3) The discussion will then focus on the particular wordset to implement cooperative multitasking. 4) It will go around and around and around for a while. 5) There will be tension between those who favor a wordset complete enough to actually write a complete portable program, and those who wish to minimize the number of words. The "completeness" advocates, regardless of whether they are right or wrong, will face the problem that more words means longer discussion and more chance of the whole thing getting tabled due to brain cell burnout. 6) The discussion will focus back on Grag Bailey's proposed minimal helpful-but-in-itself-incomplete wordset. 7) I will air my usual gripe about words that create new closures (in this case ACTIVATE< , which sends the rest of the colon definition after it to a task). I really don't like "2 definitions in one" structures (I don't like the syntax of DOES> , and I don't like Brodie's DOER .. MAKE ) 8) I will probably eventually back down under Greg's penetrating stare, and then the argument over the names will ensue. For example, the "<" at the end of "ACTIVATE<" is likely to bum out some people (me included). As for the final outcome, your guess is as good as mine (well, maybe not; I can probably eliminate a few unlikely possiblities based on past experience. But hey; I've been surprised several times, so maybe I take that back.) > I'm interested in C Forth. Can you send the Bradley software address? I think > I had lost it... Bradley Forthware, P.O. Box 4444, Mountain View, CA 94040 Cheers, Mitch Bradley, wmb@Eng.Sun.COM Brought to you by Super Global Mega Corp .com