Path: csiph.com!aioe.org!.POSTED!not-for-mail From: "HAA" Newsgroups: comp.lang.forth Subject: Re: EXIT THEN Date: Fri, 10 Feb 2017 12:15:27 +1100 Organization: Aioe.org NNTP Server Lines: 91 Message-ID: References: NNTP-Posting-Host: sICEG7SHH2BNMc+rRBU6Rw.user.gioia.aioe.org X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 Xref: csiph.com comp.lang.forth:54760 Albert van der Horst wrote: > In article , HAA wrote: > >Noticing how many times I was using the sequence EXIT THEN I did some > >research and discovered not surprisingly I was not alone. > > > >SwiftForth 227 > >VFX 533 > >GForth 358 > >Win32Forth 359 > > > >Typically found in IF conditionals EXIT THEN avoids the need for ELSE and > >the unnecessary jump it would otherwise compile. > > > >Given the frequent usage and my use of screens, I'm considering a macro > >to replace EXIT THEN. I've chosen the name END. END was once a > >synonym for UNTIL (FigForth & F79/83 reference words) but who even > >remembers that today let alone uses it. IMO the new use for END better > >befits the name. > > > >: END POSTPONE EXIT POSTPONE THEN ; IMMEDIATE > > > >alternatively > > > >: END S" POSTPONE EXIT POSTPONE THEN" EVALUATE ; IMMEDIATE > > > > Much more sensible is replacing the sequence '' BOUNDS ?DO '' by FOR > > : FOR POSTPONE SWAP POSTPONE OVER POSTPONE + POSTPONE ?DO ; > > Now we can do > > : test "AAP" FOR I C@ EMIT LOOP ; > > We could come up with an endless stream of those macro's. > > The rule must be: > if in some project some macro can be used so often that it makes > sense to introduce it, define it in the project prelude. > > I DO NOT PROPOSE `` FOR '' AS AN ADDITION TO THE STANDARD OR ANYTHING. > I JUST STATE THAT IN SOME PROJECTS IT MIGHT BE APPROPRIATE IN A > PROJECT PRELUDE. > I FIRMLY REJECT PROPOSALS LIKE ``FOR'' AND ``END'' AS A PERMANENT > ADDITION TO A FORTH. > > (Not that it helps to prevent this thread to go in the direction > of the pro's and con's of FOR.) > > Groetjes Albert Yet there are respected Forths which define ?EXIT on relatively few counts. Numbers matter but also the idea. When the numbers are very high as they are with EXIT THEN and the usage exceeds that of other conditionals such as BEGIN REPEAT then you begin wondering, as I did, whether Forth missed something. When you can point to potentially further use in Case statements then you realize it has gone cosmetics and convenience. For me, END is part of the Forth language. It's always been there - just hidden. Here's an example from SwiftForth that makes use of both END and a broadened definition for OF. Which version would you prefer to code? \ original code ... begin 0 key $20 or case [char] n of ... 1- endof [char] s of ... 1- endof [char] r of ... 1- endof [char] f of ... 1- endof endcase until ; \ using END ... begin key $20 or [char] n of ... end [char] s of ... end [char] r of ... end [char] f of ... end drop again ; BTW a check of SwiftForth for BOUNDS DO/?DO reveals a count of 22 out of 300+ files searched.