Sujet : Re: recursion
De : dxforth (at) *nospam* gmail.com (dxf)
Groupes : comp.lang.forthDate : 17. Jul 2024, 08:47:45
Autres entêtes
Organisation : Ausics - https://newsgroups.ausics.net
Message-ID : <66977721$1@news.ausics.net>
References : 1 2 3 4 5 6
User-Agent : Mozilla Thunderbird
On 16/07/2024 10:02 pm, sjack wrote:
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
forward foo
>
: bar ( n -- ) dup . 1- foo ;
>
: foo ( n -- ) dup 0> if bar else drop then ;
>
5 foo \ prints "5 4 3 2 1 "
>
Toad code using Wil Baden type local macros ( /MM: MM ):
"dup . 1- myself" /mm: bar OK
: foo dup 0> if mm bar else drop then ; OK
5 foo 5 4 3 2 1 OK
Note: The macro BAR does not remain in the system image.
I would use:
defer foo
: bar ( n -- ) dup . 1- foo ;
:noname ( n -- ) dup 0> if bar else drop then ; is foo
5 foo \ prints "5 4 3 2 1 "
DEFER may not be as fast as a directly patched definition but neither
has that prevented a generation from using it.