Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!uwm.edu!linac!att!ucbvax!BRFAPESP.BITNET!UNBCIC From: UNBCIC@BRFAPESP.BITNET Newsgroups: comp.lang.forth Subject: Guarded Commands Message-ID: <9103210417.AA14672@ucbvax.Berkeley.EDU> Date: 20 Mar 91 18:55:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: UNBCIC%BRFAPESP.BITNET@SCFVM.GSFC.NASA.GOV Organization: The Internet Lines: 57 > > These are Dijinskra structeres. > What's that you said? > Dijinskra? > (Since you called him that twice I don't consider the posibility of faulty > transmission software:) > I knew Dutch is not the easiest language for a non-native, but the man > was called Dijkstra when he left this university X years ago. *PLEASE* forgive me. I *SWEAR* that, if I had time, I would look for the correct information. I'm not sure that the first example was him. And I knew I would probably mispell the name. But..... > Furthermore I would use the original (shorther) spelling, so the constructs > become: IF guard0 DO guard0 -> statement0 -> statement0 [] guard1 [] guard1 -> statement1 -> statement1 ... ... [] guardn [] guardn -> statementn -> statementn FI OD > By the way, implementing IF/FI and DO/OD as is in Forth, will be a bit hard, > because of the prefixedness. Therefore I'd suggest a syntax like the > following: guard0 guard0 IF statement0 [] DO statement0 [] guard1 guard1 IF statement1 [] DO statement1 [] ... ... guardn guardn IF statementn FI DO statementn OD > Note that when [] gets rewritten as ELSE, you'd have a alternative > to the Baden's OF THENS and Eaker's CASE. I'll leave the implementation > pleasures to you :) No way. As I don't have time, I'll not implement, but I assure you that they can be implemented, with the same syntax in 5 lines each. Se, the IF (we should change the IF and DO names) puts a flag on stack, that is tested by FI. This flag is initialized (by IF) with 0. The -> can be a POSTPONE IF POSTPONE R> POSTPONE DROP POSTPONE TRUE POSTPONE >R, and [] an alias for THEN. Same kind of behavior for DO ... OD. > Jan Stout, Eindhoven University of Technology Thank you *VERY* much for the correction. (8-DCS) Daniel C. Sobral UNBCIC@BRFAPESP.BITNET