Sujet : Re: Nested definitions
De : anton (at) *nospam* mips.complang.tuwien.ac.at (Anton Ertl)
Groupes : comp.lang.forthDate : 03. Jul 2025, 09:34:26
Autres entêtes
Organisation : Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID : <2025Jul3.103426@mips.complang.tuwien.ac.at>
References : 1 2 3 4 5 6 7 8
User-Agent : xrn 10.11
Ruvim <
ruvim.pinka@gmail.com> writes:
On 2025-07-02 19:12, Anton Ertl wrote:
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.
I have found the limited scope to be a hindrance, not a help: When I
want to debug, I want to call the word, but if it is not visible,
that's hard. There is a compromise: The scope recognizer allows to
invoke a word X in a vocabulary V with the syntax V:X:
vocabulary foo ok
also foo definitions ok
create foo1 ok
previous definitions ok
foo1
*the terminal*:9:1: error: Undefined word
foo1<<<
Backtrace:
kernel/recognizer.fs:89:21: 0 $7FCA47A12FF8 throw
foo:foo1 hex. \ output: $7FCA47AA0DE8 ok
- anton
-- M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.htmlcomp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html New standard: https://forth-standard.org/EuroForth 2023 proceedings: http://www.euroforth.org/ef23/papers/EuroForth 2024 proceedings:
http://www.euroforth.org/ef24/papers/