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


Groups > comp.lang.forth > #10757

Re: Does ?DO force DO to become bloated?

From BruceMcF <agila61@netscape.net>
Newsgroups comp.lang.forth
Subject Re: Does ?DO force DO to become bloated?
Date 2012-03-31 07:43 -0700
Organization http://groups.google.com
Message-ID <df0f5cec-bf2a-44ec-8c8d-e85b599c6865@k4g2000yqa.googlegroups.com> (permalink)
References <jl5cp3$tev$1@speranza.aioe.org> <4f7645ed$0$23410$882e7ee2@usenet-news.net> <jl6bon$mnj$1@speranza.aioe.org>

Show all headers | View raw


On Mar 31, 3:29 am, "Rod Pemberton" <do_not_h...@noavailemail.cmm>
wrote:
> "Josh Grams" <j...@qualdan.com> wrote in message
>
> news:4f7645ed$0$23410$882e7ee2@usenet-news.net...> Rod Pemberton wrote: <jl5cp3$te...@speranza.aioe.org>
> > > Does ?DO force DO 's definition to become bloated?
>
> > It shouldn't change DO at all.
>
> ...
>
> > ?DO should basically compile `2DUP <> IF DO`,
>
> ?DO first compiles (?DO) which is currently `2DUP <>` in my case.  That's
> followed by the definition of IF inlined into ?DO .  I've yet to find out
> why IF itself won't work there.  I thought it was an issue with needing
> COMPILE or [COMPILE] but maybe IF just needed to be in (?DO) ...
> Continuing, that's followed by compiling (DO) which is what DO compiles.
> Finally, there is a HERE at the end of ?DO .  The HERE is definately
> different from what you mentioned.  Otherwise, it's probably equivalent.
>
> So, when using ?DO there are two HERE addresses on the stack, one due to the
> IF and one by the explict HERE.  One address is for looping and the other is
> for the conditional branch in ?DO .  That means that LOOP and +LOOP are
> always getting two addresses from ?DO .  So, they must be coded to use both
> of them.  That means that DO must also supply two addresses, not just one.
> Yes?  If only one is provided by DO , then a stack underflow will occur.
> I.e., that implies that DO 's code must mirror the implementation of ?DO in
> terms of placing addresses on the stack.  If LOOP and +LOOP didn't have to
> backfill in the conditional forward address from ?DO , then DO would be
> simpler.
>
> (Just prior to me posting this, Ms. Rather posted a solution which doesn't
> require both DO and ?DO putting two addresses onto the stack.)
>
> > [...] and the IF's compile-time info should be stored so
> > that it will be resolved as if it were a LEAVE.
>
> Are you talking about the linked-list created "leave" and "rake" chaining
> implementation of LEAVES?
>
> > Do you have LEAVE yet?
>
> No.
>
> > I'd implement that before ?DO.
>
> Why?

> ISTM that the "leaves-rake" method is complicated.

How complicate it is depends on how you implement it. If you implement
it for simplicity, it can be as simple as postponing a THEN as long as
loop count is greater than zero:

: RAKE-LEAVES ( C: u1 u2 count*orig -- )
   leave-count @
   BEGIN ?DUP WHILE SWAP POSTPONE THEN REPEAT
   leave-count ! do-height ! ;

> ISTM also that it doesn't fit well with the other
> control-flow words.

Quite, its a exceptional exit from the do-loop, and does not use the
regular compile-time structure stack.

> From what I can tell, it seems that ANS LEAVE also
> requires a forward reference branch address that must be
> resolved, like ?DO

Yes, which is why if you have LEAVE already, the simplest way to do ?
DO is to hook into that system.

> I'm not sure yet how to work that into DO ?DO LOOP +LOOP yet.

In that case, have DO drop a "0" on the stack before it drops its
"dest", and have ?DO drop a "TRUE" on the stack after it postpones its
"IF".

Then at the right time in LOOP and +LOOP, you have:
   ... IF POSTPONE THEN THEN ...

... and you're set until you work out how you are going to handle
LEAVE.

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


Thread

Does ?DO force DO to become bloated? "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-03-30 18:40 -0400
  Re: Does ?DO force DO to become bloated? "Elizabeth D. Rather" <erather@forth.com> - 2012-03-30 13:24 -1000
    Re: Does ?DO force DO to become bloated? Hans Bezemer <the.beez.speaks@gmail.com> - 2012-03-31 20:56 +0200
      Re: Does ?DO force DO to become bloated? "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-04-01 06:06 -0400
        Re: Does ?DO force DO to become bloated? "Elizabeth D. Rather" <erather@forth.com> - 2012-04-01 07:57 -1000
        Re: Does ?DO force DO to become bloated? Hans Bezemer <the.beez.speaks@gmail.com> - 2012-04-02 19:14 +0200
          Re: Does ?DO force DO to become bloated? "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-04-03 06:02 -0400
      Re: Does ?DO force DO to become bloated? BruceMcF <agila61@netscape.net> - 2012-03-31 12:32 -0700
  Re: Does ?DO force DO to become bloated? Josh Grams <josh@qualdan.com> - 2012-03-30 23:46 +0000
    Re: Does ?DO force DO to become bloated? "Elizabeth D. Rather" <erather@forth.com> - 2012-03-30 20:58 -1000
      Re: Does ?DO force DO to become bloated? "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-03-31 03:31 -0400
        Re: Does ?DO force DO to become bloated? "Elizabeth D. Rather" <erather@forth.com> - 2012-03-31 08:25 -1000
        Re: Does ?DO force DO to become bloated? BruceMcF <agila61@netscape.net> - 2012-03-31 12:02 -0700
          Re: Does ?DO force DO to become bloated? "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-04-03 06:01 -0400
            Re: Does ?DO force DO to become bloated? "Elizabeth D. Rather" <erather@forth.com> - 2012-04-03 08:38 -1000
              Re: Does ?DO force DO to become bloated? "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-04-04 05:24 -0400
                Re: Does ?DO force DO to become bloated? "Elizabeth D. Rather" <erather@forth.com> - 2012-04-04 07:44 -1000
                Re: Does ?DO force DO to become bloated? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-04-05 11:51 +0000
                Re: Does ?DO force DO to become bloated? mhx@iae.nl (Marcel Hendrix) - 2012-04-05 21:10 +0200
                Re: Does ?DO force DO to become bloated? "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-04-05 09:33 -0400
                Re: Does ?DO force DO to become bloated? "Elizabeth D. Rather" <erather@forth.com> - 2012-04-05 08:12 -1000
                Re: Does ?DO force DO to become bloated? BruceMcF <agila61@netscape.net> - 2012-04-04 07:23 -0700
                Re: Does ?DO force DO to become bloated? "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-04-05 09:50 -0400
                Re: Does ?DO force DO to become bloated? BruceMcF <agila61@netscape.net> - 2012-04-05 12:26 -0700
    Re: Does ?DO force DO to become bloated? "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-03-31 03:29 -0400
      Re: Does ?DO force DO to become bloated? Josh Grams <josh@qualdan.com> - 2012-03-31 09:58 +0000
        Re: Does ?DO force DO to become bloated? segher <segher@kernel.crashing.org> - 2012-03-31 04:21 -0700
        Re: Does ?DO force DO to become bloated? BruceMcF <agila61@netscape.net> - 2012-03-31 07:19 -0700
      Re: Does ?DO force DO to become bloated? Hans Bezemer <the.beez.speaks@gmail.com> - 2012-03-31 15:29 +0200
      Re: Does ?DO force DO to become bloated? "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-03-31 20:28 -0400
        Re: Does ?DO force DO to become bloated? BruceMcF <agila61@netscape.net> - 2012-03-31 19:48 -0700
      Re: Does ?DO force DO to become bloated? BruceMcF <agila61@netscape.net> - 2012-03-31 07:43 -0700

csiph-web