| Deutsch English Français Italiano |
|
<v76i8v$1di81$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!3.eu.feeder.erje.net!feeder.erje.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: sjack@dontemail.me (sjack)
Newsgroups: comp.lang.forth
Subject: Re: recursion
Date: Tue, 16 Jul 2024 19:39:11 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <v76i8v$1di81$1@dont-email.me>
References: <v6c8v0$3usoe$1@dont-email.me> <v71gpb$jsug$1@solani.org> <nnd$79e41f47$2235e236@caa216183355b959> <d8a7bf3190d012f4d6e588cf7f4f4ee1@www.novabbs.com> <2024Jul15.152917@mips.complang.tuwien.ac.at> <v75ngv$18mqt$1@dont-email.me> <e2af0d8018b224af669d59511c376dcd@www.novabbs.com>
Injection-Date: Tue, 16 Jul 2024 21:39:11 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c6ded16f80f870a458509d108808c3e6";
logging-data="1493249"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/eJgTatSoFsHRHjB0iEa4p"
User-Agent: tin/2.6.2-20220130 ("Convalmore") (Linux/6.5.0-41-generic (x86_64))
Cancel-Lock: sha1:k/LWzWOa6ob5r8IaE273NJo0W6k=
Bytes: 2419
minforth <minforth@gmx.net> wrote:
> Pretzel coding. I wondered what that could be useful for.
Kind of wonder why myself; more focused on ways to do the given
example rather than why it's needed to be a forward case. By the
way, the macro example I gave wasn't right; see example 5 for
correct way. Example 4 seems to me the most proper way as it
uses all basic Forth elements. Example 3 seems the best but it's
not a forwarding case so it may not be applicable to what's
being sought.
Example 1
: bar dup . 1- [ here tmp! ] noop ;
: foo dup 0> if bar [ latest pfa cfa tmp@ ! ] else drop then ;
5 foo5 4 3 2 1
Example 2
: forward here tmp! 0 , ; immediate
: resolve latest pfa cfa tmp@ ! ; immediate
: bar dup . 1- forward ;
: foo dup 0> if bar resolve else drop then ;
5 foo5 4 3 2 1
Example 3
: bar dup . 1- ;
: foo dup 0> if bar myself else drop then ;
5 foo5 4 3 2 1
Example 4
defer foo
: bar dup . 1- foo ;
anon dup 0> if bar else drop then ; is foo
5 foo5 4 3 2 1
Example 5
"here tmp! 0 ," /mm: forward
"latest pfa cfa tmp@ !" /mm: resolve
: bar dup . 1- [ mm forward ] ;
: foo dup 0> if bar [ mm resolve ] else drop then ;
5 foo5 4 3 2 1
-- remove all macros
mm.clear
-- do again
5 foo5 4 3 2 1
--
me