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


Groups > comp.lang.forth > #41852

Re: old `leave` renamed to `exhaust`

From Marcos Cruz <null_email_so_use_my_contact_page@programandala.net>
Newsgroups comp.lang.forth
Subject Re: old `leave` renamed to `exhaust`
Date 2015-09-08 16:25 +0000
Organization Aioe.org NNTP Server
Message-ID <msn26b$tmd$1@speranza.aioe.org> (permalink)
References <msks3o$6fv$1@speranza.aioe.org> <mslpeq$umg$1@speranza.aioe.org>

Show all headers | View raw


En/Je/On 2015-09-08, HAA <someone@microsoft.com> escribió/skribis/wrote:

> Interesting that you find 79-LEAVE "very useful".  Example?

Maybe "very useful" was not a precise wording :)

I find Forth-79 `leave` especially clear when a loop consists of several
parts and the exit condition depends on some of them, but the iteration
must be completed in any case. Example:

	: something  ( n1 n2 -- i*x )
	  do
		part1 cond1? if  79-leave  then
		part2
		part3 cond3? if  79-leave  then
		part4
		part5 cond5? if  79-leave  then
	  loop  ;

Of course you can use Forth-83 `leave` instead several ways, depending
on the way the "conds" work, consuming parameters left by their
correspondent "parts" or not:

	: something  ( n1 n2 -- i*x )
	  do
		part1 cond1? part2 part3 cond3? part4 part5 cond5?
		or or if  83-leave  then
	  loop  ;

	: something  ( n1 n2 -- i*x )
	  do
		part1 part2 part3 part4 part5
		cond1? cond3? cond5?  or or if  83-leave  then
	  loop  ;

Forth-79 `leave` seems clearer and simpler to me in these cases, not to
mention when the "parts" of the loop leave items on the stack, or when
the number of exit conditions changes during the development.

I know that's a very specific example, but my point is:

Forth-83 `leave` leaves the loop immediately, what was a great
improvement over the old behaviour, and that is what is needed most of
the times. On the other hand, Forth-79 `leave` forces the current
iteration to be the last one, what is not exactly the same, even if its
usual function was to leave the loop at the end of the iteration.  *I
find that subtle difference very useful*, and I miss it, because
sometimes the old `leave` is exactly what I need to code: this iteration
must the last one.

That's why I keep the old `leave` with a different name.

Regards,

-- 
Marcos Cruz
http://programandala.net

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


Thread

old `leave` renamed to `exhaust` Marcos Cruz <null_email_so_use_my_contact_page@programandala.net> - 2015-09-07 20:29 +0000
  Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-08 14:52 +1000
    Re: old `leave` renamed to `exhaust` Mark Wills <markwills1970@gmail.com> - 2015-09-08 00:57 -0700
      Re: old `leave` renamed to `exhaust` Bernd Paysan <bernd.paysan@gmx.de> - 2015-09-08 15:19 +0200
    Re: old `leave` renamed to `exhaust` Marcos Cruz <null_email_so_use_my_contact_page@programandala.net> - 2015-09-08 16:25 +0000
      Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-09 11:39 +1000
        Re: old `leave` renamed to `exhaust` Marcos Cruz <null_email_so_use_my_contact_page@programandala.net> - 2015-09-09 10:42 +0000
          Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-10 14:05 +1000
            Re: old `leave` renamed to `exhaust` Marcos Cruz <null_email_so_use_my_contact_page@programandala.net> - 2015-09-10 13:33 +0000
              Re: old `leave` renamed to `exhaust` Coos Haak <chforth@hccnet.nl> - 2015-09-10 22:04 +0200
                Re: old `leave` renamed to `exhaust` Coos Haak <chforth@hccnet.nl> - 2015-09-10 22:13 +0200
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-11 13:14 +1000
                Re: old `leave` renamed to `exhaust` Coos Haak <chforth@hccnet.nl> - 2015-09-11 12:30 +0200
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-11 21:47 +1000
                Re: old `leave` renamed to `exhaust` Bernd Paysan <bernd.paysan@gmx.de> - 2015-09-11 14:09 +0200
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-12 11:29 +1000
                Re: old `leave` renamed to `exhaust` "Elizabeth D. Rather" <erather@forth.com> - 2015-09-11 16:05 -1000
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-14 12:25 +1000
                Re: old `leave` renamed to `exhaust` "Elizabeth D. Rather" <erather@forth.com> - 2015-09-13 17:53 -1000
                Re: old `leave` renamed to `exhaust` anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-09-14 08:33 +0000
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-15 16:55 +1000
                Re: old `leave` renamed to `exhaust` hughaguilar96@gmail.com - 2015-09-15 01:46 -0700
                Re: old `leave` renamed to `exhaust` Coos Haak <chforth@hccnet.nl> - 2015-09-15 15:14 +0200
                Re: old `leave` renamed to `exhaust` anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-09-15 15:13 +0000
                Re: old `leave` renamed to `exhaust` hughaguilar96@gmail.com - 2015-09-15 16:13 -0700
                Re: old `leave` renamed to `exhaust` jim.brakefield@ieee.org - 2015-09-15 17:05 -0700
                Re: old `leave` renamed to `exhaust` hughaguilar96@gmail.com - 2015-09-15 18:35 -0700
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-19 11:42 +1000
                Re: old `leave` renamed to `exhaust` anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-09-19 10:48 +0000
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-20 00:01 +1000
                Re: old `leave` renamed to `exhaust` anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-09-19 15:02 +0000
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-21 15:51 +1000
                Re: old `leave` renamed to `exhaust` "Elizabeth D. Rather" <erather@forth.com> - 2015-09-15 08:45 -1000
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-16 11:18 +1000
                Re: old `leave` renamed to `exhaust` anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-09-16 06:10 +0000
                Re: old `leave` renamed to `exhaust` "HAA" <someone@microsoft.com> - 2015-09-17 15:15 +1000
                Re: old `leave` renamed to `exhaust` anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-09-17 06:04 +0000
                Re: old `leave` renamed to `exhaust` Coos Haak <chforth@hccnet.nl> - 2015-09-11 14:16 +0200

csiph-web