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


Groups > comp.lang.forth > #8768

Re: Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay?

From Arnold Doray <invalid@invalid.com>
Newsgroups comp.lang.forth
Subject Re: Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay?
Date 2012-01-10 13:51 +0000
Organization A noiseless patient Spider
Message-ID <jehfpu$9de$1@dont-email.me> (permalink)
References <19111298.516.1326191150632.JavaMail.geo-discussion-forums@yqbu38>

Show all headers | View raw


On Tue, 10 Jan 2012 02:25:50 -0800, gavino wrote:

> : 5x x x x x x ;
> : 20x 5x 5x 5x 5x ;
> 
> http://www.ultratechnology.com/moore4th.htm
> 
> I don't understand how conditional can be minimized...they seem to be
> with loops almost the basic block of a program..

Almost any terminating loop contains a conditional to test for 
termination. 

CPU pipelining is improved by reducing conditionals. Modern CPUs have 
branch prediction, but these aren't always successful, in which case the 
pipline needs to be flushed, lowering the CPU's throughput. This is which 
is why you want to avoid conditionals especially if they are repeated 
often, like in tight loops. 

So, as I understand it, CM advocates using factorization as an 
alternative (eg, the examples you gave above). This obviates the need for 
conditionals to test for loop termination. But:

a) They could lead to (arguably) less readable code, 

b) It's harder to break from a loop.  

c) Really makes sense only when you *must* do something N times. 
Otherwise, you need to introduce a conditional to know when to terminate, 
bringing you back to square one. 

Hope this helps.

Cheers,
Arnold



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


Thread

Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay? gavino <gavcomedy@gmail.com> - 2012-01-10 02:25 -0800
  Re: Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay? Arnold Doray <invalid@invalid.com> - 2012-01-10 13:51 +0000
    Re: Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay? "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-01-11 07:21 -0500
      Re: Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay? Alex McDonald <blog@rivadpm.com> - 2012-01-11 04:29 -0800
        Re: Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay? nmm1@cam.ac.uk - 2012-01-11 12:48 +0000
        Re: Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay? "Andy (Super) Glew" <andy@SPAM.comp-arch.net> - 2012-01-11 09:25 -0800
          Re: Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay? jgk@panix.com (Joe keane) - 2012-01-13 17:47 +0000
            Re: Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay? "Andy (Super) Glew" <andy@SPAM.comp-arch.net> - 2012-01-13 10:09 -0800
              Re: Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay? jgk@panix.com (Joe keane) - 2012-01-14 04:16 +0000
                Re: Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay? Terje Mathisen <"terje.mathisen at tmsw.no"> - 2012-01-14 10:23 +0100
                Re: Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay? "Paul A. Clayton" <paaronclayton@gmail.com> - 2012-01-14 10:10 -0800
                Re: Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay? "Andy (Super) Glew" <andy@SPAM.comp-arch.net> - 2012-01-14 17:15 -0800
      Re: Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay? Terje Mathisen <"terje.mathisen at tmsw.no"> - 2012-01-11 14:33 +0100
      Re: Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay? Arnold Doray <invalid@invalid.com> - 2012-01-11 15:03 +0000
  Re: Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay? jc <john.comeau@gmail.com> - 2012-01-13 11:26 -0800
    Re: Can someone explain step by step how one avoid many conditional in forth as described in Moore Fourth essay? jc <john.comeau@gmail.com> - 2012-01-13 11:43 -0800

csiph-web