Path: csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: What is the word to break a do while loop? Date: Wed, 04 Feb 2015 18:50:54 -0500 Organization: Aioe.org NNTP Server Lines: 45 Message-ID: References: <53c95926-d610-4995-8746-5a9166ea3b75@googlegroups.com> <12dlay6wqdj74.s5sar1seepvu$.dlg@40tude.net> NNTP-Posting-Host: n4wpt9zq8xR26Ttf9mo2BA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:36287 On Wed, 04 Feb 2015 06:54:55 -0500, Coos Haak wrote: > Op Tue, 3 Feb 2015 23:24:31 -0800 (PST) schreef Faisal: >> I tried LEAVE, but it is not working >> >> : test >> begin dup 0 >= while >> dup . >> 1 - >> exitapp@ 1 = IF >> leave >> then >> repeat >> . >> ; > > There is no do-while loop in Forth. You wrote a correct > begin-while-repeat loop, but leave does not work here, > use the word exit here. You can use exit in begin-until > and begin-again loops too. ... > Remember that exit leaves > the word test and does not reach the . after repeat. It's good someone mentioned that, but no one told him that using two words solves the problem with EXIT exiting the current definition: : testbody begin ... while ... if exit then ... repeat ; : test testbody . ; Rod Pemberton