Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #36287

Re: What is the word to break a do while loop?

From "Rod Pemberton" <buzz@notnotnontnooatno.cmm>
Newsgroups comp.lang.forth
Subject Re: What is the word to break a do while loop?
Date 2015-02-04 18:50 -0500
Organization Aioe.org NNTP Server
Message-ID <op.xtj4i4ecv6dtjm@localhost> (permalink)
References <53c95926-d610-4995-8746-5a9166ea3b75@googlegroups.com> <12dlay6wqdj74.s5sar1seepvu$.dlg@40tude.net>

Show all headers | View raw


On Wed, 04 Feb 2015 06:54:55 -0500, Coos Haak <chforth@hccnet.nl> 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

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

What is the word to break a do while loop? Faisal <faisalm83@gmail.com> - 2015-02-03 23:24 -0800
  Re: What is the word to break a do while loop? Mark Wills <markwills1970@gmail.com> - 2015-02-04 01:53 -0800
  Re: What is the word to break a do while loop? Mark Wills <markwills1970@gmail.com> - 2015-02-04 02:15 -0800
  Re: What is the word to break a do while loop? Coos Haak <chforth@hccnet.nl> - 2015-02-04 12:54 +0100
    Re: What is the word to break a do while loop? "Rod Pemberton" <buzz@notnotnontnooatno.cmm> - 2015-02-04 18:50 -0500
    Re: What is the word to break a do while loop? hughaguilar96@gmail.com - 2015-02-04 18:29 -0800
      Re: What is the word to break a do while loop? hughaguilar96@gmail.com - 2015-02-04 18:43 -0800
  Re: What is the word to break a do while loop? JennyB <jennybrien@googlemail.com> - 2015-02-04 05:53 -0800
    Re: What is the word to break a do while loop? hughaguilar96@gmail.com - 2015-02-04 18:36 -0800
      Re: What is the word to break a do while loop? "HAA" <someone@microsoft.com> - 2015-02-08 17:31 +1100
        Re: What is the word to break a do while loop? hughaguilar96@gmail.com - 2015-02-08 09:13 -0800
          Re: What is the word to break a do while loop? "HAA" <someone@microsoft.com> - 2015-02-09 16:45 +1100
            Re: What is the word to break a do while loop? hughaguilar96@gmail.com - 2015-02-09 22:36 -0800
              Re: What is the word to break a do while loop? "HAA" <someone@microsoft.com> - 2015-02-11 10:30 +1100
  Re: What is the word to break a do while loop? lehs <skydda.barnen@gmail.com> - 2015-02-05 08:54 -0800

csiph-web