| Deutsch English Français Italiano |
|
<1043of9$3k2oi$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Ruvim <ruvim.pinka@gmail.com>
Newsgroups: comp.lang.forth
Subject: Re: Nested definitions
Date: Wed, 2 Jul 2025 20:58:17 +0400
Organization: A noiseless patient Spider
Lines: 64
Message-ID: <1043of9$3k2oi$1@dont-email.me>
References: <1f433fabcb4d053d16cbc098dedc6c370608ac01@i2pn2.org>
<2025Jun23.071834@mips.complang.tuwien.ac.at>
<a004d0f4acf945e054db77d86a4544fc@www.novabbs.com>
<1042s2o$3d58h$1@dont-email.me> <nnd$42f4ab46$0b513441@af5c09ac13877827>
<1043831$3ggg9$1@dont-email.me> <2025Jul2.171200@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 02 Jul 2025 18:58:18 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b6dd42a864d78e38891f20145fd68000";
logging-data="3803922"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+WO/eqId+SBt7iwObi44Px"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:KnRmJX+TI5A5R7cUq9519Ww+v/M=
Content-Language: en-US
In-Reply-To: <2025Jul2.171200@mips.complang.tuwien.ac.at>
On 2025-07-02 19:12, Anton Ertl wrote:
> Ruvim <ruvim.pinka@gmail.com> writes:
>> On 2025-07-02 15:37, albert@spenarnc.xs4all.nl wrote:
>>> Or it has not even know it, if [ is smart enough to compile a jump to
>>> after ].
>>
>> This can be tricky because the following should work:
>>
>> create foo [ 123 , ] [ 456 ,
>>
>> : bar [ ' foo compile, 123 lit, ] ;
>
> Or something. Anyway, [ and ] are used for a variety of purposes and
> trying to smarten them seems fraught with pitfalls. If one really
> wants to have
>
> : foo ... [ : bar ... ; ] ... ;
>
> work, it may be better to put the smarts into : and ;. E.g., on a
> system with sections, they could switch to another section and back.
Yes, and I wonder why introducing new words like `<:` and `;>` is better
than putting the smarts into `:` and `;`.
> The benefit of defining a normal colon definition inside another colon
> definition eludes me, however. Maybe mutual recursion, but the need
> is rare and deferred words handle that well.
As I can see, the idea is that the name of a nested definition has the
limited scope — the same as a local variable, and it is not visible
outside of the containing definition.
So, the program like:
: foo
...
[ : bar ... ; ]
...
bar
...
;
Is equivalent to:
get-current wordlist push-order definitions
: bar ... ;
set-current
: foo
...
bar
...
;
previous
--
Ruvim