Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

fortune: cpu time/usefulness ratio too high -- core dumped.


devel / comp.lang.forth / Learn forth: how forth nests words properly ?

SubjectAuthor
* Learn forth: how forth nests words properly ?fabianor...@gmail.com
+- Re: Learn forth: how forth nests words properly ?minf...@arcor.de
`* Re: Learn forth: how forth nests words properly ?Anton Ertl
 +- Re: Learn forth: how forth nests words properly ?fabianor...@gmail.com
 +* Re: Learn forth: how forth nests words properly ?fabianor...@gmail.com
 |+- Re: Learn forth: how forth nests words properly ?fabianor...@gmail.com
 |+* Re: Learn forth: how forth nests words properly ?Mark Wills
 ||`* Re: Learn forth: how forth nests words properly ?fabianor...@gmail.com
 || `* Re: Learn forth: how forth nests words properly ?Mark Wills
 ||  `- Re: Learn forth: how forth nests words properly ?dxforth
 |+* Re: Learn forth: how forth nests words properly ?dxforth
 ||`* Re: Learn forth: how forth nests words properly ?fabianor...@gmail.com
 || `- Re: Learn forth: how forth nests words properly ?dxforth
 |`- Re: Learn forth: how forth nests words properly ?Anton Ertl
 `* Re: Learn forth: how forth nests words properly ?fabianor...@gmail.com
  +- Re: Learn forth: how forth nests words properly ?S Jack
  +* Re: Learn forth: how forth nests words properly ?Brian Fox
  |`* Re: Learn forth: how forth nests words properly ?minf...@arcor.de
  | `* Re: Learn forth: how forth nests words properly ?fabianor...@gmail.com
  |  +* Re: Learn forth: how forth nests words properly ?fabianor...@gmail.com
  |  |`- Re: Learn forth: how forth nests words properly ?Howerd Oakford
  |  +- Re: Learn forth: how forth nests words properly ?Mark Wills
  |  `* Re: Learn forth: how forth nests words properly ?Brian Fox
  |   `* Re: Learn forth: how forth nests words properly ?fabianor...@gmail.com
  |    +* Re: Learn forth: how forth nests words properly ?fabianor...@gmail.com
  |    |+* Re: Learn forth: how forth nests words properly ?fabianor...@gmail.com
  |    ||`* Re: Learn forth: how forth nests words properly ?fabianor...@gmail.com
  |    || `- Re: Learn forth: how forth nests words properly ?fabianor...@gmail.com
  |    |+* Re: Learn forth: how forth nests words properly ?Brian Fox
  |    ||`- Re: Learn forth: how forth nests words properly ?Paul Rubin
  |    |`* Re: Learn forth: how forth nests words properly ?Anton Ertl
  |    | `- Re: Learn forth: how forth nests words properly ?dxforth
  |    `- Re: Learn forth: how forth nests words properly ?Howerd Oakford
  `- Re: Learn forth: how forth nests words properly ?Anton Ertl

Pages:12
Learn forth: how forth nests words properly ?

<7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16567&group=comp.lang.forth#16567

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:7f02:: with SMTP id f2mr22363420qtk.601.1643782241587;
Tue, 01 Feb 2022 22:10:41 -0800 (PST)
X-Received: by 2002:ac8:5d8a:: with SMTP id d10mr21889215qtx.279.1643782241421;
Tue, 01 Feb 2022 22:10:41 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Tue, 1 Feb 2022 22:10:41 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=168.121.177.102; posting-account=OMrK2AoAAACPu8JcOP64zhFwVmCz0fk3
NNTP-Posting-Host: 168.121.177.102
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
Subject: Learn forth: how forth nests words properly ?
From: fabianor...@gmail.com (fabianor...@gmail.com)
Injection-Date: Wed, 02 Feb 2022 06:10:41 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 14
 by: fabianor...@gmail.co - Wed, 2 Feb 2022 06:10 UTC

I'm studying the forth language and I have a question about word nesting: suppose I created a word "program version 1.0" and it would stay inside the word "info" along with other words, then I modified "program version" for some reason ( version 2.0). The case is that now version of the program is not 2.0 but 1.0 .
If I were programming defining words and one better grouped several together soon it could become hell with a minimum of carelessness! Forgetting to redefine some words.
I know that the field pointers still point to their old definitions and for design reasons (I believe) because it is minimalist and a lot of use in limited systems it doesn't adopt garbage collection but "overwrites another definition in the dictionary" seems pretty smart for the embedded world, but if the code grows too large, it looks like this will give a lot of headache.
So... how is forth's way of dealing with this?

Re: Learn forth: how forth nests words properly ?

<6199d6e8-ebfe-4f04-b12b-68af732ed906n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16568&group=comp.lang.forth#16568

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:7f4d:: with SMTP id g13mr22257616qtk.173.1643789947909;
Wed, 02 Feb 2022 00:19:07 -0800 (PST)
X-Received: by 2002:ac8:5fd5:: with SMTP id k21mr9961615qta.63.1643789947737;
Wed, 02 Feb 2022 00:19:07 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 2 Feb 2022 00:19:07 -0800 (PST)
In-Reply-To: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=79.224.111.239; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 79.224.111.239
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6199d6e8-ebfe-4f04-b12b-68af732ed906n@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Wed, 02 Feb 2022 08:19:07 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 21
 by: minf...@arcor.de - Wed, 2 Feb 2022 08:19 UTC

fabianor...@gmail.com schrieb am Mittwoch, 2. Februar 2022 um 07:10:42 UTC+1:
> I'm studying the forth language and I have a question about word nesting: suppose I created a word "program version 1.0" and it would stay inside the word "info" along with other words, then I modified "program version" for some reason ( version 2.0). The case is that now version of the program is not 2.0 but 1.0 .
> If I were programming defining words and one better grouped several together soon it could become hell with a minimum of carelessness! Forgetting to redefine some words.
> I know that the field pointers still point to their old definitions and for design reasons (I believe) because it is minimalist and a lot of use in limited systems it doesn't adopt garbage collection but "overwrites another definition in the dictionary" seems pretty smart for the embedded world, but if the code grows too large, it looks like this will give a lot of headache.
> So... how is forth's way of dealing with this?

Please bear with me: ANY language would give you headache
when you code version information into function/word names.
Doing this makes the namespace version-dependent.
Better let data (like version count) be data, and functions be functions.

Re: Learn forth: how forth nests words properly ?

<2022Feb2.114118@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16571&group=comp.lang.forth#16571

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Learn forth: how forth nests words properly ?
Date: Wed, 02 Feb 2022 10:41:18 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 38
Message-ID: <2022Feb2.114118@mips.complang.tuwien.ac.at>
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="9ab28c567b9bc496f167b43be856b3c6";
logging-data="3351"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18iew3JTBCZ5KmS57w2kOg0"
Cancel-Lock: sha1:4DHFU3BUAjv6UD3t1UOiZq1b0f0=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Wed, 2 Feb 2022 10:41 UTC

"fabianor...@gmail.com" <fabianorezende26@gmail.com> writes:
>I'm studying the forth language and I have a question about word nesting: s=
>uppose I created a word "program version 1.0" and it would stay inside the =
>word "info" along with other words, then I modified "program version" for s=
>ome reason ( version 2.0). The case is that now version of the program is n=
>ot 2.0 but 1.0 .
>If I were programming defining words and one better grouped several togethe=
>r soon it could become hell with a minimum of carelessness! Forgetting to r=
>edefine some words.
>I know that the field pointers still point to their old definitions and for=
> design reasons (I believe) because it is minimalist and a lot of use in li=
>mited systems it doesn't adopt garbage collection but "overwrites another d=
>efinition in the dictionary" seems pretty smart for the embedded world, but=
> if the code grows too large, it looks like this will give a lot of headach=
>e.
>So... how is forth's way of dealing with this?

It's not clear if I understand what you mean, but I interpret the
question as:

You load new versions of a program on top of old versions, repeatedly,
and wonder about the memory consumption of this approach, and how
Forth deals with it.

My anser to that question is that if you load the program N times, you
will typically consume N times as much memory as when you load it
once. There are several ways to deal with that in Forth: One is to
end the current session and start a new one when you want to load a
new version. Another is to forget the old program (with FORGET,
MARKER, or (nonstandard, but used by some) ANEW) and then load the new
one without ending the session.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Learn forth: how forth nests words properly ?

<383076f0-a887-418f-87dd-1b350fd079b0n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16576&group=comp.lang.forth#16576

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:4453:: with SMTP id w19mr8209200qkp.465.1643811185522;
Wed, 02 Feb 2022 06:13:05 -0800 (PST)
X-Received: by 2002:a05:6214:29ec:: with SMTP id jv12mr26311190qvb.87.1643811185273;
Wed, 02 Feb 2022 06:13:05 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 2 Feb 2022 06:13:05 -0800 (PST)
In-Reply-To: <2022Feb2.114118@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=168.121.177.102; posting-account=OMrK2AoAAACPu8JcOP64zhFwVmCz0fk3
NNTP-Posting-Host: 168.121.177.102
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com> <2022Feb2.114118@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <383076f0-a887-418f-87dd-1b350fd079b0n@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: fabianor...@gmail.com (fabianor...@gmail.com)
Injection-Date: Wed, 02 Feb 2022 14:13:05 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 64
 by: fabianor...@gmail.co - Wed, 2 Feb 2022 14:13 UTC

Em quarta-feira, 2 de fevereiro de 2022 às 07:50:05 UTC-3, Anton Ertl escreveu:
> "fabianor...@gmail.com" <fabianor...@gmail.com> writes:
> >I'm studying the forth language and I have a question about word nesting: s=
> >uppose I created a word "program version 1.0" and it would stay inside the =
> >word "info" along with other words, then I modified "program version" for s=
> >ome reason ( version 2.0). The case is that now version of the program is n> >ot 2.0 but 1.0 .
> >If I were programming defining words and one better grouped several togethe=
> >r soon it could become hell with a minimum of carelessness! Forgetting to r=
> >edefine some words.
> >I know that the field pointers still point to their old definitions and for=
> > design reasons (I believe) because it is minimalist and a lot of use in li=
> >mited systems it doesn't adopt garbage collection but "overwrites another d=
> >efinition in the dictionary" seems pretty smart for the embedded world, but=
> > if the code grows too large, it looks like this will give a lot of headach> >e.
> >So... how is forth's way of dealing with this?
> It's not clear if I understand what you mean, but I interpret the
> question as:
>
> You load new versions of a program on top of old versions, repeatedly,
> and wonder about the memory consumption of this approach, and how
> Forth deals with it.
>
> My anser to that question is that if you load the program N times, you
> will typically consume N times as much memory as when you load it
> once. There are several ways to deal with that in Forth: One is to
> end the current session and start a new one when you want to load a
> new version. Another is to forget the old program (with FORGET,
> MARKER, or (nonstandard, but used by some) ANEW) and then load the new
> one without ending the session.
>
> - anton
> --
> M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
> comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
> New standard: http://www.forth200x.org/forth200x.html
> EuroForth 2021: https://euro.theforth.net/2021
acho que ficou longo demais e não ficou claro.
exemplo:
: my-word word-1 word-2 word-3 ;
se eu modificar word-1 agora tenho duas word-1! A que foi redefinida e a outra na definição antiga de my-word. Bem é só redefinir my-word também que tudo volta ao esperado.
O que parecia ser algo trivial vai se tornar algo que tenho que ter muito cuidado.
A medida que o programa cresce e eu preciso renomear palavras seja porque encontrei um bug , seja porque precisei atualizar o sistema... seja lá o motivo , se uma palavra de dentro de outra mudar , teremos 2 palavras com o mesmo nome e precisaria me lembrar onde estas palavras estão aninhadas.
Então pensei que deveria ter uma maneira melhor de se lidar com isso.

Re: Learn forth: how forth nests words properly ?

<fd0576c0-90c0-463a-b23e-137f5be5593en@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16577&group=comp.lang.forth#16577

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ad4:594f:: with SMTP id eo15mr26033584qvb.59.1643811319351;
Wed, 02 Feb 2022 06:15:19 -0800 (PST)
X-Received: by 2002:a05:6214:29ea:: with SMTP id jv10mr26524650qvb.46.1643811319110;
Wed, 02 Feb 2022 06:15:19 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 2 Feb 2022 06:15:18 -0800 (PST)
In-Reply-To: <2022Feb2.114118@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=168.121.177.102; posting-account=OMrK2AoAAACPu8JcOP64zhFwVmCz0fk3
NNTP-Posting-Host: 168.121.177.102
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com> <2022Feb2.114118@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fd0576c0-90c0-463a-b23e-137f5be5593en@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: fabianor...@gmail.com (fabianor...@gmail.com)
Injection-Date: Wed, 02 Feb 2022 14:15:19 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 63
 by: fabianor...@gmail.co - Wed, 2 Feb 2022 14:15 UTC

Em quarta-feira, 2 de fevereiro de 2022 às 07:50:05 UTC-3, Anton Ertl escreveu:
> "fabianor...@gmail.com" <fabianor...@gmail.com> writes:
> >I'm studying the forth language and I have a question about word nesting: s=
> >uppose I created a word "program version 1.0" and it would stay inside the =
> >word "info" along with other words, then I modified "program version" for s=
> >ome reason ( version 2.0). The case is that now version of the program is n> >ot 2.0 but 1.0 .
> >If I were programming defining words and one better grouped several togethe=
> >r soon it could become hell with a minimum of carelessness! Forgetting to r=
> >edefine some words.
> >I know that the field pointers still point to their old definitions and for=
> > design reasons (I believe) because it is minimalist and a lot of use in li=
> >mited systems it doesn't adopt garbage collection but "overwrites another d=
> >efinition in the dictionary" seems pretty smart for the embedded world, but=
> > if the code grows too large, it looks like this will give a lot of headach> >e.
> >So... how is forth's way of dealing with this?
> It's not clear if I understand what you mean, but I interpret the
> question as:
>
> You load new versions of a program on top of old versions, repeatedly,
> and wonder about the memory consumption of this approach, and how
> Forth deals with it.
>
> My anser to that question is that if you load the program N times, you
> will typically consume N times as much memory as when you load it
> once. There are several ways to deal with that in Forth: One is to
> end the current session and start a new one when you want to load a
> new version. Another is to forget the old program (with FORGET,
> MARKER, or (nonstandard, but used by some) ANEW) and then load the new
> one without ending the session.
>
> - anton
> --
> M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
> comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
> New standard: http://www.forth200x.org/forth200x.html
> EuroForth 2021: https://euro.theforth.net/2021
I think it was too long and not clear.
example:
: my-word word-1 word-2 word-3 ;
if i modify word-1 i now have two word-1! The one that was redefined and the other on the old definition of my-word. Well, just reset my-word too and everything goes back to what you expected.
What seemed to be something trivial is going to become something I have to be very careful about.
As the program grows and I need to rename words either because I found a bug, or because I needed to update the system... whatever the reason, if a word inside another changes, we will have 2 words with the same name and I would need to remember where these words are nested.
So I thought there must be a better way to handle this.

Re: Learn forth: how forth nests words properly ?

<5019d28b-604e-4325-8fdc-f1660a683726n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16578&group=comp.lang.forth#16578

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:7f87:: with SMTP id z7mr17991196qtj.365.1643811732639;
Wed, 02 Feb 2022 06:22:12 -0800 (PST)
X-Received: by 2002:ad4:5dc1:: with SMTP id m1mr27318038qvh.51.1643811732441;
Wed, 02 Feb 2022 06:22:12 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 2 Feb 2022 06:22:12 -0800 (PST)
In-Reply-To: <fd0576c0-90c0-463a-b23e-137f5be5593en@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=168.121.177.102; posting-account=OMrK2AoAAACPu8JcOP64zhFwVmCz0fk3
NNTP-Posting-Host: 168.121.177.102
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
<2022Feb2.114118@mips.complang.tuwien.ac.at> <fd0576c0-90c0-463a-b23e-137f5be5593en@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5019d28b-604e-4325-8fdc-f1660a683726n@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: fabianor...@gmail.com (fabianor...@gmail.com)
Injection-Date: Wed, 02 Feb 2022 14:22:12 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 73
 by: fabianor...@gmail.co - Wed, 2 Feb 2022 14:22 UTC

Em quarta-feira, 2 de fevereiro de 2022 às 11:15:20 UTC-3, fabianor...@gmail.com escreveu:
> Em quarta-feira, 2 de fevereiro de 2022 às 07:50:05 UTC-3, Anton Ertl escreveu:
> > "fabianor...@gmail.com" <fabianor...@gmail.com> writes:
> > >I'm studying the forth language and I have a question about word nesting: s=
> > >uppose I created a word "program version 1.0" and it would stay inside the =
> > >word "info" along with other words, then I modified "program version" for s=
> > >ome reason ( version 2.0). The case is that now version of the program is n=
> > >ot 2.0 but 1.0 .
> > >If I were programming defining words and one better grouped several togethe=
> > >r soon it could become hell with a minimum of carelessness! Forgetting to r=
> > >edefine some words.
> > >I know that the field pointers still point to their old definitions and for=
> > > design reasons (I believe) because it is minimalist and a lot of use in li=
> > >mited systems it doesn't adopt garbage collection but "overwrites another d=
> > >efinition in the dictionary" seems pretty smart for the embedded world, but=
> > > if the code grows too large, it looks like this will give a lot of headach=
> > >e.
> > >So... how is forth's way of dealing with this?
> > It's not clear if I understand what you mean, but I interpret the
> > question as:
> >
> > You load new versions of a program on top of old versions, repeatedly,
> > and wonder about the memory consumption of this approach, and how
> > Forth deals with it.
> >
> > My anser to that question is that if you load the program N times, you
> > will typically consume N times as much memory as when you load it
> > once. There are several ways to deal with that in Forth: One is to
> > end the current session and start a new one when you want to load a
> > new version. Another is to forget the old program (with FORGET,
> > MARKER, or (nonstandard, but used by some) ANEW) and then load the new
> > one without ending the session.
> >
> > - anton
> > --
> > M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
> > comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
> > New standard: http://www.forth200x.org/forth200x.html
> > EuroForth 2021: https://euro.theforth.net/2021
> I think it was too long and not clear.
> example:
> : my-word word-1 word-2 word-3 ;
> if i modify word-1 i now have two word-1! The one that was redefined and the other on the old definition of my-word. Well, just reset my-word too and everything goes back to what you expected.
> What seemed to be something trivial is going to become something I have to be very careful about.
> As the program grows and I need to rename words either because I found a bug, or because I needed to update the system... whatever the reason, if a word inside another changes, we will have 2 words with the same name and I would need to remember where these words are nested.
> So I thought there must be a better way to handle this.
Now I have to rethink that it doesn't seem like a good idea to use a string counted inside a definition, but a variable with allot and not using literals but variables as well.
Marker seems like something to be used with care because what it does is pretty radical and I'm going to walk on eggshells again.

Re: Learn forth: how forth nests words properly ?

<b9ef124f-5ccf-47cd-9d0b-69a3fe46d387n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16579&group=comp.lang.forth#16579

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:573:: with SMTP id p19mr12475126qkp.615.1643812700770;
Wed, 02 Feb 2022 06:38:20 -0800 (PST)
X-Received: by 2002:ad4:5de2:: with SMTP id jn2mr24779991qvb.25.1643812700563;
Wed, 02 Feb 2022 06:38:20 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 2 Feb 2022 06:38:20 -0800 (PST)
In-Reply-To: <2022Feb2.114118@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=168.121.177.102; posting-account=OMrK2AoAAACPu8JcOP64zhFwVmCz0fk3
NNTP-Posting-Host: 168.121.177.102
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com> <2022Feb2.114118@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b9ef124f-5ccf-47cd-9d0b-69a3fe46d387n@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: fabianor...@gmail.com (fabianor...@gmail.com)
Injection-Date: Wed, 02 Feb 2022 14:38:20 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 56
 by: fabianor...@gmail.co - Wed, 2 Feb 2022 14:38 UTC

Em quarta-feira, 2 de fevereiro de 2022 às 07:50:05 UTC-3, Anton Ertl escreveu:
> "fabianor...@gmail.com" <fabianor...@gmail.com> writes:
> >I'm studying the forth language and I have a question about word nesting: s=
> >uppose I created a word "program version 1.0" and it would stay inside the =
> >word "info" along with other words, then I modified "program version" for s=
> >ome reason ( version 2.0). The case is that now version of the program is n> >ot 2.0 but 1.0 .
> >If I were programming defining words and one better grouped several togethe=
> >r soon it could become hell with a minimum of carelessness! Forgetting to r=
> >edefine some words.
> >I know that the field pointers still point to their old definitions and for=
> > design reasons (I believe) because it is minimalist and a lot of use in li=
> >mited systems it doesn't adopt garbage collection but "overwrites another d=
> >efinition in the dictionary" seems pretty smart for the embedded world, but=
> > if the code grows too large, it looks like this will give a lot of headach> >e.
> >So... how is forth's way of dealing with this?
> It's not clear if I understand what you mean, but I interpret the
> question as:
>
> You load new versions of a program on top of old versions, repeatedly,
> and wonder about the memory consumption of this approach, and how
> Forth deals with it.
>
> My anser to that question is that if you load the program N times, you
> will typically consume N times as much memory as when you load it
> once. There are several ways to deal with that in Forth: One is to
> end the current session and start a new one when you want to load a
> new version. Another is to forget the old program (with FORGET,
> MARKER, or (nonstandard, but used by some) ANEW) and then load the new
> one without ending the session.
>
> - anton
> --
> M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
> comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
> New standard: http://www.forth200x.org/forth200x.html
> EuroForth 2021: https://euro.theforth.net/2021
In other languages u recompile or interpreted overwrite the function(word) and move on(of course depending on the size to recompile... )
Forth uses a dictionary that creates another definition and does not overwrite or erase the previous one. Which ends up creating two words with the same name in the system without me realizing it.
As I'm new to forth I figured I shouldn't be doing things the forth way.

Re: Learn forth: how forth nests words properly ?

<3c62f257-0fe2-48d1-bbef-6fbac7fcf1dcn@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16582&group=comp.lang.forth#16582

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5c16:: with SMTP id i22mr23853640qti.669.1643821365706;
Wed, 02 Feb 2022 09:02:45 -0800 (PST)
X-Received: by 2002:a05:620a:2481:: with SMTP id i1mr10050471qkn.159.1643821365260;
Wed, 02 Feb 2022 09:02:45 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 2 Feb 2022 09:02:45 -0800 (PST)
In-Reply-To: <b9ef124f-5ccf-47cd-9d0b-69a3fe46d387n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:3f7a:20d0:41d7:d8bb:1005:ca34;
posting-account=V5nGoQoAAAC_P2U0qnxm2kC0s1jNJXJa
NNTP-Posting-Host: 2600:1700:3f7a:20d0:41d7:d8bb:1005:ca34
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
<2022Feb2.114118@mips.complang.tuwien.ac.at> <b9ef124f-5ccf-47cd-9d0b-69a3fe46d387n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3c62f257-0fe2-48d1-bbef-6fbac7fcf1dcn@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: sdwjac...@gmail.com (S Jack)
Injection-Date: Wed, 02 Feb 2022 17:02:45 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 7
 by: S Jack - Wed, 2 Feb 2022 17:02 UTC

On Wednesday, February 2, 2022 at 8:38:21 AM UTC-6, fabianor...@gmail.com wrote:
> Forth uses a dictionary that creates another definition and does not overwrite or erase the previous one. Which ends up creating two words with the same name in the system without me realizing it.

: foo ." boo " ; ok
: foo ." bah " ; foo isn't unique
ok
--
me

Re: Learn forth: how forth nests words properly ?

<98d367c9-3d64-4627-8ea4-5cd7d16590cbn@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16587&group=comp.lang.forth#16587

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ad4:5766:: with SMTP id r6mr20003733qvx.77.1643824524824;
Wed, 02 Feb 2022 09:55:24 -0800 (PST)
X-Received: by 2002:a05:620a:44d4:: with SMTP id y20mr15614654qkp.272.1643824524566;
Wed, 02 Feb 2022 09:55:24 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 2 Feb 2022 09:55:24 -0800 (PST)
In-Reply-To: <fd0576c0-90c0-463a-b23e-137f5be5593en@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=92.40.195.183; posting-account=-Z7-HwoAAAAWOrLQDWUcFYPD8_KiaWMt
NNTP-Posting-Host: 92.40.195.183
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
<2022Feb2.114118@mips.complang.tuwien.ac.at> <fd0576c0-90c0-463a-b23e-137f5be5593en@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <98d367c9-3d64-4627-8ea4-5cd7d16590cbn@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: markwill...@gmail.com (Mark Wills)
Injection-Date: Wed, 02 Feb 2022 17:55:24 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 75
 by: Mark Wills - Wed, 2 Feb 2022 17:55 UTC

On Wednesday, February 2, 2022 at 2:15:20 PM UTC, fabianor...@gmail.com wrote:
> Em quarta-feira, 2 de fevereiro de 2022 às 07:50:05 UTC-3, Anton Ertl escreveu:
> > "fabianor...@gmail.com" <fabianor...@gmail.com> writes:
> > >I'm studying the forth language and I have a question about word nesting: s=
> > >uppose I created a word "program version 1.0" and it would stay inside the =
> > >word "info" along with other words, then I modified "program version" for s=
> > >ome reason ( version 2.0). The case is that now version of the program is n=
> > >ot 2.0 but 1.0 .
> > >If I were programming defining words and one better grouped several togethe=
> > >r soon it could become hell with a minimum of carelessness! Forgetting to r=
> > >edefine some words.
> > >I know that the field pointers still point to their old definitions and for=
> > > design reasons (I believe) because it is minimalist and a lot of use in li=
> > >mited systems it doesn't adopt garbage collection but "overwrites another d=
> > >efinition in the dictionary" seems pretty smart for the embedded world, but=
> > > if the code grows too large, it looks like this will give a lot of headach=
> > >e.
> > >So... how is forth's way of dealing with this?
> > It's not clear if I understand what you mean, but I interpret the
> > question as:
> >
> > You load new versions of a program on top of old versions, repeatedly,
> > and wonder about the memory consumption of this approach, and how
> > Forth deals with it.
> >
> > My anser to that question is that if you load the program N times, you
> > will typically consume N times as much memory as when you load it
> > once. There are several ways to deal with that in Forth: One is to
> > end the current session and start a new one when you want to load a
> > new version. Another is to forget the old program (with FORGET,
> > MARKER, or (nonstandard, but used by some) ANEW) and then load the new
> > one without ending the session.
> >
> > - anton
> > --
> > M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
> > comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
> > New standard: http://www.forth200x.org/forth200x.html
> > EuroForth 2021: https://euro.theforth.net/2021
> I think it was too long and not clear.
> example:
> : my-word word-1 word-2 word-3 ;
> if i modify word-1 i now have two word-1! The one that was redefined and the other on the old definition of my-word. Well, just reset my-word too and everything goes back to what you expected.
> What seemed to be something trivial is going to become something I have to be very careful about.
> As the program grows and I need to rename words either because I found a bug, or because I needed to update the system... whatever the reason, if a word inside another changes, we will have 2 words with the same name and I would need to remember where these words are nested.
> So I thought there must be a better way to handle this.

DEFER and IS are the answer you seek.

There is a write-up (for beginners) here: http://turboforth.net/resources/defer-is.html
(the above website doesn't support HTTPS, sorry - I'll ger around to installing it one day)

Re: Learn forth: how forth nests words properly ?

<b8167b82-f884-4d74-ab4f-39a0797af03bn@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16591&group=comp.lang.forth#16591

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:18e:: with SMTP id s14mr24314386qtw.391.1643837162559;
Wed, 02 Feb 2022 13:26:02 -0800 (PST)
X-Received: by 2002:a05:622a:13cb:: with SMTP id p11mr24318035qtk.210.1643837162284;
Wed, 02 Feb 2022 13:26:02 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 2 Feb 2022 13:26:02 -0800 (PST)
In-Reply-To: <98d367c9-3d64-4627-8ea4-5cd7d16590cbn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=168.121.177.102; posting-account=OMrK2AoAAACPu8JcOP64zhFwVmCz0fk3
NNTP-Posting-Host: 168.121.177.102
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
<2022Feb2.114118@mips.complang.tuwien.ac.at> <fd0576c0-90c0-463a-b23e-137f5be5593en@googlegroups.com>
<98d367c9-3d64-4627-8ea4-5cd7d16590cbn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b8167b82-f884-4d74-ab4f-39a0797af03bn@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: fabianor...@gmail.com (fabianor...@gmail.com)
Injection-Date: Wed, 02 Feb 2022 21:26:02 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 81
 by: fabianor...@gmail.co - Wed, 2 Feb 2022 21:26 UTC

Em quarta-feira, 2 de fevereiro de 2022 às 14:55:26 UTC-3, Mark Wills escreveu:
> On Wednesday, February 2, 2022 at 2:15:20 PM UTC, fabianor...@gmail.com wrote:
> > Em quarta-feira, 2 de fevereiro de 2022 às 07:50:05 UTC-3, Anton Ertl escreveu:
> > > "fabianor...@gmail.com" <fabianor...@gmail.com> writes:
> > > >I'm studying the forth language and I have a question about word nesting: s=
> > > >uppose I created a word "program version 1.0" and it would stay inside the =
> > > >word "info" along with other words, then I modified "program version" for s=
> > > >ome reason ( version 2.0). The case is that now version of the program is n=
> > > >ot 2.0 but 1.0 .
> > > >If I were programming defining words and one better grouped several togethe=
> > > >r soon it could become hell with a minimum of carelessness! Forgetting to r=
> > > >edefine some words.
> > > >I know that the field pointers still point to their old definitions and for=
> > > > design reasons (I believe) because it is minimalist and a lot of use in li=
> > > >mited systems it doesn't adopt garbage collection but "overwrites another d=
> > > >efinition in the dictionary" seems pretty smart for the embedded world, but=
> > > > if the code grows too large, it looks like this will give a lot of headach=
> > > >e.
> > > >So... how is forth's way of dealing with this?
> > > It's not clear if I understand what you mean, but I interpret the
> > > question as:
> > >
> > > You load new versions of a program on top of old versions, repeatedly,
> > > and wonder about the memory consumption of this approach, and how
> > > Forth deals with it.
> > >
> > > My anser to that question is that if you load the program N times, you
> > > will typically consume N times as much memory as when you load it
> > > once. There are several ways to deal with that in Forth: One is to
> > > end the current session and start a new one when you want to load a
> > > new version. Another is to forget the old program (with FORGET,
> > > MARKER, or (nonstandard, but used by some) ANEW) and then load the new
> > > one without ending the session.
> > >
> > > - anton
> > > --
> > > M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
> > > comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
> > > New standard: http://www.forth200x.org/forth200x.html
> > > EuroForth 2021: https://euro.theforth.net/2021
> > I think it was too long and not clear.
> > example:
> > : my-word word-1 word-2 word-3 ;
> > if i modify word-1 i now have two word-1! The one that was redefined and the other on the old definition of my-word. Well, just reset my-word too and everything goes back to what you expected.
> > What seemed to be something trivial is going to become something I have to be very careful about.
> > As the program grows and I need to rename words either because I found a bug, or because I needed to update the system... whatever the reason, if a word inside another changes, we will have 2 words with the same name and I would need to remember where these words are nested.
> > So I thought there must be a better way to handle this.
> DEFER and IS are the answer you seek.
>
> There is a write-up (for beginners) here: http://turboforth.net/resources/defer-is.html
> (the above website doesn't support HTTPS, sorry - I'll ger around to installing it one day)
Searching for forth on youtube landed on your channel yesterday.
The link you sent me seems to have very didactic tutorials, thank you.
But wouldn't this solution imply having to mark practically every word with defer/is?

Re: Learn forth: how forth nests words properly ?

<stf5t2$la6$1@gioia.aioe.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16593&group=comp.lang.forth#16593

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Learn forth: how forth nests words properly ?
Date: Thu, 3 Feb 2022 10:59:30 +1100
Organization: Aioe.org NNTP Server
Message-ID: <stf5t2$la6$1@gioia.aioe.org>
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
<2022Feb2.114118@mips.complang.tuwien.ac.at>
<fd0576c0-90c0-463a-b23e-137f5be5593en@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="21830"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.1
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Wed, 2 Feb 2022 23:59 UTC

On 3/02/2022 01:15, fabianor...@gmail.com wrote:
> ...
> I think it was too long and not clear.
> example:
> : my-word word-1 word-2 word-3 ;
> if i modify word-1 i now have two word-1! The one that was redefined and the other on the old definition of my-word. Well, just reset my-word too and everything goes back to what you expected.
> What seemed to be something trivial is going to become something I have to be very careful about.
> As the program grows and I need to rename words either because I found a bug, or because I needed to update the system... whatever the reason, if a word inside another changes, we will have 2 words with the same name and I would need to remember where these words are nested.
> So I thought there must be a better way to handle this.

There needs to be good reason to have two words with the same name.
If you can guarantee they never conflict e.g. IF in forth is different
from IF in the assembler, or in overloading where there's no intention
of using the old version, it's no problem. Otherwise use different names.

When you want a word's definition to change and it must reflect in all
previous uses of the word, there is DEFER as Mark indicated.

Re: Learn forth: how forth nests words properly ?

<64848254-df9d-487f-8600-b5a11e3365fen@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16596&group=comp.lang.forth#16596

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:18e:: with SMTP id s14mr25005386qtw.391.1643852025364;
Wed, 02 Feb 2022 17:33:45 -0800 (PST)
X-Received: by 2002:a05:620a:94e:: with SMTP id w14mr21791954qkw.485.1643852024985;
Wed, 02 Feb 2022 17:33:44 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 2 Feb 2022 17:33:44 -0800 (PST)
In-Reply-To: <stf5t2$la6$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=168.121.177.102; posting-account=OMrK2AoAAACPu8JcOP64zhFwVmCz0fk3
NNTP-Posting-Host: 168.121.177.102
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
<2022Feb2.114118@mips.complang.tuwien.ac.at> <fd0576c0-90c0-463a-b23e-137f5be5593en@googlegroups.com>
<stf5t2$la6$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <64848254-df9d-487f-8600-b5a11e3365fen@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: fabianor...@gmail.com (fabianor...@gmail.com)
Injection-Date: Thu, 03 Feb 2022 01:33:45 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 33
 by: fabianor...@gmail.co - Thu, 3 Feb 2022 01:33 UTC

Em quarta-feira, 2 de fevereiro de 2022 às 20:59:35 UTC-3, dxforth escreveu:
> On 3/02/2022 01:15, fabianor...@gmail.com wrote:
> > ...
> > I think it was too long and not clear.
> > example:
> > : my-word word-1 word-2 word-3 ;
> > if i modify word-1 i now have two word-1! The one that was redefined and the other on the old definition of my-word. Well, just reset my-word too and everything goes back to what you expected.
> > What seemed to be something trivial is going to become something I have to be very careful about.
> > As the program grows and I need to rename words either because I found a bug, or because I needed to update the system... whatever the reason, if a word inside another changes, we will have 2 words with the same name and I would need to remember where these words are nested.
> > So I thought there must be a better way to handle this.
> There needs to be good reason to have two words with the same name.
> If you can guarantee they never conflict e.g. IF in forth is different
> from IF in the assembler, or in overloading where there's no intention
> of using the old version, it's no problem. Otherwise use different names.
>
> When you want a word's definition to change and it must reflect in all
> previous uses of the word, there is DEFER as Mark indicated.
But that's the point! It's not having two words. nesting words could end up with 2 words.
: word-1 ." first definition " ;
: my-word word-1 ;
: word-1 ." word-1 redefined" ;
word-1 - word-1 redefined
my-word ( word-1 from inside my-word will print ) first definition
resets seems to me something like "walking on eggshells"
or nothing trivial.

Re: Learn forth: how forth nests words properly ?

<stfg5a$1mup$1@gioia.aioe.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16597&group=comp.lang.forth#16597

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Learn forth: how forth nests words properly ?
Date: Thu, 3 Feb 2022 13:54:34 +1100
Organization: Aioe.org NNTP Server
Message-ID: <stfg5a$1mup$1@gioia.aioe.org>
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
<2022Feb2.114118@mips.complang.tuwien.ac.at>
<fd0576c0-90c0-463a-b23e-137f5be5593en@googlegroups.com>
<stf5t2$la6$1@gioia.aioe.org>
<64848254-df9d-487f-8600-b5a11e3365fen@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="56281"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.1
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Thu, 3 Feb 2022 02:54 UTC

On 3/02/2022 12:33, fabianor...@gmail.com wrote:
> Em quarta-feira, 2 de fevereiro de 2022 às 20:59:35 UTC-3, dxforth escreveu:
>> On 3/02/2022 01:15, fabianor...@gmail.com wrote:
>> > ...
>> > I think it was too long and not clear.
>> > example:
>> > : my-word word-1 word-2 word-3 ;
>> > if i modify word-1 i now have two word-1! The one that was redefined and the other on the old definition of my-word. Well, just reset my-word too and everything goes back to what you expected.
>> > What seemed to be something trivial is going to become something I have to be very careful about.
>> > As the program grows and I need to rename words either because I found a bug, or because I needed to update the system... whatever the reason, if a word inside another changes, we will have 2 words with the same name and I would need to remember where these words are nested.
>> > So I thought there must be a better way to handle this.
>> There needs to be good reason to have two words with the same name.
>> If you can guarantee they never conflict e.g. IF in forth is different
>> from IF in the assembler, or in overloading where there's no intention
>> of using the old version, it's no problem. Otherwise use different names.
>>
>> When you want a word's definition to change and it must reflect in all
>> previous uses of the word, there is DEFER as Mark indicated.

> But that's the point! It's not having two words. nesting words could end up with 2 words.
> : word-1 ." first definition " ;
> : my-word word-1 ;
> : word-1 ." word-1 redefined" ;
> word-1 - word-1 redefined
> my-word ( word-1 from inside my-word will print ) first definition
> resets seems to me something like "walking on eggshells"
> or nothing trivial.

Nothing is reset. After compilation 'my-word' contains a reference to the
original action whose name was 'word-1'. When you defined a new word with
that name, the linkage to the original action was lost. Subsequent words
that use 'word-1' will use the latest action defined under that name.

Re: Learn forth: how forth nests words properly ?

<8c1f7760-62a1-4ec8-888a-4df55507bbf0n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16610&group=comp.lang.forth#16610

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ae9:eb4f:: with SMTP id b76mr127889qkg.690.1643927727498;
Thu, 03 Feb 2022 14:35:27 -0800 (PST)
X-Received: by 2002:a05:6214:d0c:: with SMTP id 12mr84596qvh.46.1643927727184;
Thu, 03 Feb 2022 14:35:27 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Thu, 3 Feb 2022 14:35:27 -0800 (PST)
In-Reply-To: <b8167b82-f884-4d74-ab4f-39a0797af03bn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=92.40.195.183; posting-account=-Z7-HwoAAAAWOrLQDWUcFYPD8_KiaWMt
NNTP-Posting-Host: 92.40.195.183
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
<2022Feb2.114118@mips.complang.tuwien.ac.at> <fd0576c0-90c0-463a-b23e-137f5be5593en@googlegroups.com>
<98d367c9-3d64-4627-8ea4-5cd7d16590cbn@googlegroups.com> <b8167b82-f884-4d74-ab4f-39a0797af03bn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8c1f7760-62a1-4ec8-888a-4df55507bbf0n@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: markwill...@gmail.com (Mark Wills)
Injection-Date: Thu, 03 Feb 2022 22:35:27 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 106
 by: Mark Wills - Thu, 3 Feb 2022 22:35 UTC

On Wednesday, February 2, 2022 at 9:26:03 PM UTC, fabianor...@gmail.com wrote:
> Em quarta-feira, 2 de fevereiro de 2022 às 14:55:26 UTC-3, Mark Wills escreveu:
> > On Wednesday, February 2, 2022 at 2:15:20 PM UTC, fabianor...@gmail.com wrote:
> > > Em quarta-feira, 2 de fevereiro de 2022 às 07:50:05 UTC-3, Anton Ertl escreveu:
> > > > "fabianor...@gmail.com" <fabianor...@gmail.com> writes:
> > > > >I'm studying the forth language and I have a question about word nesting: s=
> > > > >uppose I created a word "program version 1.0" and it would stay inside the =
> > > > >word "info" along with other words, then I modified "program version" for s=
> > > > >ome reason ( version 2.0). The case is that now version of the program is n=
> > > > >ot 2.0 but 1.0 .
> > > > >If I were programming defining words and one better grouped several togethe=
> > > > >r soon it could become hell with a minimum of carelessness! Forgetting to r=
> > > > >edefine some words.
> > > > >I know that the field pointers still point to their old definitions and for=
> > > > > design reasons (I believe) because it is minimalist and a lot of use in li=
> > > > >mited systems it doesn't adopt garbage collection but "overwrites another d=
> > > > >efinition in the dictionary" seems pretty smart for the embedded world, but=
> > > > > if the code grows too large, it looks like this will give a lot of headach=
> > > > >e.
> > > > >So... how is forth's way of dealing with this?
> > > > It's not clear if I understand what you mean, but I interpret the
> > > > question as:
> > > >
> > > > You load new versions of a program on top of old versions, repeatedly,
> > > > and wonder about the memory consumption of this approach, and how
> > > > Forth deals with it.
> > > >
> > > > My anser to that question is that if you load the program N times, you
> > > > will typically consume N times as much memory as when you load it
> > > > once. There are several ways to deal with that in Forth: One is to
> > > > end the current session and start a new one when you want to load a
> > > > new version. Another is to forget the old program (with FORGET,
> > > > MARKER, or (nonstandard, but used by some) ANEW) and then load the new
> > > > one without ending the session.
> > > >
> > > > - anton
> > > > --
> > > > M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
> > > > comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
> > > > New standard: http://www.forth200x.org/forth200x.html
> > > > EuroForth 2021: https://euro.theforth.net/2021
> > > I think it was too long and not clear.
> > > example:
> > > : my-word word-1 word-2 word-3 ;
> > > if i modify word-1 i now have two word-1! The one that was redefined and the other on the old definition of my-word. Well, just reset my-word too and everything goes back to what you expected.
> > > What seemed to be something trivial is going to become something I have to be very careful about.
> > > As the program grows and I need to rename words either because I found a bug, or because I needed to update the system... whatever the reason, if a word inside another changes, we will have 2 words with the same name and I would need to remember where these words are nested.
> > > So I thought there must be a better way to handle this.
> > DEFER and IS are the answer you seek.
> >
> > There is a write-up (for beginners) here: http://turboforth.net/resources/defer-is.html
> > (the above website doesn't support HTTPS, sorry - I'll ger around to installing it one day)
> Searching for forth on youtube landed on your channel yesterday.
> The link you sent me seems to have very didactic tutorials, thank you.
> But wouldn't this solution imply having to mark practically every word with defer/is?

Only the ones the think you'll need to change:

defer maybeBuggy

: try-this1 <some code> ;
' try-this1 is maybeBuggy
maybeBuggy
<CRASH! Stack underflow!>
: try-this2 <some code> dup ;
' try-this2 is maybeBuggy
maybeBuggy
ok

<take the rest of the day of - you win!>

You'll only define deferred words while working at the Forth REPL, but once a word is debugged and saved in your source file, it will not need to be a deferred word - 'cos you already debugged it - you know it works :-)

Re: Learn forth: how forth nests words properly ?

<sthn9i$14kq$1@gioia.aioe.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16611&group=comp.lang.forth#16611

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Learn forth: how forth nests words properly ?
Date: Fri, 4 Feb 2022 10:08:34 +1100
Organization: Aioe.org NNTP Server
Message-ID: <sthn9i$14kq$1@gioia.aioe.org>
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
<2022Feb2.114118@mips.complang.tuwien.ac.at>
<fd0576c0-90c0-463a-b23e-137f5be5593en@googlegroups.com>
<98d367c9-3d64-4627-8ea4-5cd7d16590cbn@googlegroups.com>
<b8167b82-f884-4d74-ab4f-39a0797af03bn@googlegroups.com>
<8c1f7760-62a1-4ec8-888a-4df55507bbf0n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="37530"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Thu, 3 Feb 2022 23:08 UTC

On 4/02/2022 09:35, Mark Wills wrote:
> On Wednesday, February 2, 2022 at 9:26:03 PM UTC, fabianor...@gmail.com wrote:
>> Em quarta-feira, 2 de fevereiro de 2022 às 14:55:26 UTC-3, Mark Wills escreveu:
>> > On Wednesday, February 2, 2022 at 2:15:20 PM UTC, fabianor...@gmail.com wrote:
>> > > Em quarta-feira, 2 de fevereiro de 2022 às 07:50:05 UTC-3, Anton Ertl escreveu:
>> > > > "fabianor...@gmail.com" <fabianor...@gmail.com> writes:
>> > > > >I'm studying the forth language and I have a question about word nesting: s=
>> > > > >uppose I created a word "program version 1.0" and it would stay inside the =
>> > > > >word "info" along with other words, then I modified "program version" for s=
>> > > > >ome reason ( version 2.0). The case is that now version of the program is n=
>> > > > >ot 2.0 but 1.0 .
>> > > > >If I were programming defining words and one better grouped several togethe=
>> > > > >r soon it could become hell with a minimum of carelessness! Forgetting to r=
>> > > > >edefine some words.
>> > > > >I know that the field pointers still point to their old definitions and for=
>> > > > > design reasons (I believe) because it is minimalist and a lot of use in li=
>> > > > >mited systems it doesn't adopt garbage collection but "overwrites another d=
>> > > > >efinition in the dictionary" seems pretty smart for the embedded world, but=
>> > > > > if the code grows too large, it looks like this will give a lot of headach=
>> > > > >e.
>> > > > >So... how is forth's way of dealing with this?
>> > > > It's not clear if I understand what you mean, but I interpret the
>> > > > question as:
>> > > >
>> > > > You load new versions of a program on top of old versions, repeatedly,
>> > > > and wonder about the memory consumption of this approach, and how
>> > > > Forth deals with it.
>> > > >
>> > > > My anser to that question is that if you load the program N times, you
>> > > > will typically consume N times as much memory as when you load it
>> > > > once. There are several ways to deal with that in Forth: One is to
>> > > > end the current session and start a new one when you want to load a
>> > > > new version. Another is to forget the old program (with FORGET,
>> > > > MARKER, or (nonstandard, but used by some) ANEW) and then load the new
>> > > > one without ending the session.
>> > > >
>> > > > - anton
>> > > > --
>> > > > M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
>> > > > comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
>> > > > New standard: http://www.forth200x.org/forth200x.html
>> > > > EuroForth 2021: https://euro.theforth.net/2021
>> > > I think it was too long and not clear.
>> > > example:
>> > > : my-word word-1 word-2 word-3 ;
>> > > if i modify word-1 i now have two word-1! The one that was redefined and the other on the old definition of my-word. Well, just reset my-word too and everything goes back to what you expected.
>> > > What seemed to be something trivial is going to become something I have to be very careful about.
>> > > As the program grows and I need to rename words either because I found a bug, or because I needed to update the system... whatever the reason, if a word inside another changes, we will have 2 words with the same name and I would need to remember where these words are nested.
>> > > So I thought there must be a better way to handle this.
>> > DEFER and IS are the answer you seek.
>> >
>> > There is a write-up (for beginners) here: http://turboforth.net/resources/defer-is.html
>> > (the above website doesn't support HTTPS, sorry - I'll ger around to installing it one day)
>> Searching for forth on youtube landed on your channel yesterday.
>> The link you sent me seems to have very didactic tutorials, thank you.
>> But wouldn't this solution imply having to mark practically every word with defer/is?
>
> Only the ones the think you'll need to change:
>
> defer maybeBuggy
>
> : try-this1 <some code> ;
> ' try-this1 is maybeBuggy
> maybeBuggy
> <CRASH! Stack underflow!>
> : try-this2 <some code> dup ;
> ' try-this2 is maybeBuggy
> maybeBuggy
> ok
>
> <take the rest of the day of - you win!>
>
> You'll only define deferred words while working at the Forth REPL, but once a word is debugged and saved in your source file, it will not need to be a deferred word - 'cos you already debugged it - you know it works :-)

Can't say I've used DEFER for debugging. Forth applications are typically created
'bottom up'. Sorting out the low level routines first informs what the higher level
stuff should be. Whether other languages do it differently I wouldn't know.

Re: Learn forth: how forth nests words properly ?

<c82076ea-f43b-4644-8ee3-e7d80b523857n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16614&group=comp.lang.forth#16614

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:29ec:: with SMTP id jv12mr545195qvb.87.1643941406117;
Thu, 03 Feb 2022 18:23:26 -0800 (PST)
X-Received: by 2002:a05:622a:13cb:: with SMTP id p11mr722264qtk.210.1643941405888;
Thu, 03 Feb 2022 18:23:25 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Thu, 3 Feb 2022 18:23:25 -0800 (PST)
In-Reply-To: <b9ef124f-5ccf-47cd-9d0b-69a3fe46d387n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2607:fea8:2a60:9ae:4075:3484:14d3:c65d;
posting-account=2z7GawoAAADc70p5SM5AbaCyzjLblS3g
NNTP-Posting-Host: 2607:fea8:2a60:9ae:4075:3484:14d3:c65d
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
<2022Feb2.114118@mips.complang.tuwien.ac.at> <b9ef124f-5ccf-47cd-9d0b-69a3fe46d387n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c82076ea-f43b-4644-8ee3-e7d80b523857n@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: brian....@brianfox.ca (Brian Fox)
Injection-Date: Fri, 04 Feb 2022 02:23:26 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 98
 by: Brian Fox - Fri, 4 Feb 2022 02:23 UTC

On Wednesday, February 2, 2022 at 9:38:21 AM UTC-5, fabianor...@gmail.com wrote:
> Em quarta-feira, 2 de fevereiro de 2022 às 07:50:05 UTC-3, Anton Ertl escreveu:
> > "fabianor...@gmail.com" <fabianor...@gmail.com> writes:
> > >I'm studying the forth language and I have a question about word nesting: s=
> > >uppose I created a word "program version 1.0" and it would stay inside the =
> > >word "info" along with other words, then I modified "program version" for s=
> > >ome reason ( version 2.0). The case is that now version of the program is n=
> > >ot 2.0 but 1.0 .
> > >If I were programming defining words and one better grouped several togethe=
> > >r soon it could become hell with a minimum of carelessness! Forgetting to r=
> > >edefine some words.
> > >I know that the field pointers still point to their old definitions and for=
> > > design reasons (I believe) because it is minimalist and a lot of use in li=
> > >mited systems it doesn't adopt garbage collection but "overwrites another d=
> > >efinition in the dictionary" seems pretty smart for the embedded world, but=
> > > if the code grows too large, it looks like this will give a lot of headach=
> > >e.
> > >So... how is forth's way of dealing with this?
> > It's not clear if I understand what you mean, but I interpret the
> > question as:
> >
> > You load new versions of a program on top of old versions, repeatedly,
> > and wonder about the memory consumption of this approach, and how
> > Forth deals with it.
> >
> > My anser to that question is that if you load the program N times, you
> > will typically consume N times as much memory as when you load it
> > once. There are several ways to deal with that in Forth: One is to
> > end the current session and start a new one when you want to load a
> > new version. Another is to forget the old program (with FORGET,
> > MARKER, or (nonstandard, but used by some) ANEW) and then load the new
> > one without ending the session.
> >
> > - anton
> > --
> > M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
> > comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
> > New standard: http://www.forth200x.org/forth200x.html
> > EuroForth 2021: https://euro.theforth.net/2021
> In other languages u recompile or interpreted overwrite the function(word) and move on(of course depending on the size to recompile... )
> Forth uses a dictionary that creates another definition and does not overwrite or erase the previous one. Which ends up creating two words with the same name in the system without me realizing it.
> As I'm new to forth I figured I shouldn't be doing things the forth way.

Something that has not been mentioned is how the Forth dictionary is searched.
The search starts at the last definition, in other words from the back to front.

If I create:
: WORD1 ." Hello" ;
: WORD1 ." World ;
: WORD1 ." WHAT?" ;

Yes three words with the same name are created
BUT! Forth can now only find the last one defined. Why?
Because the search begins at the _ LAST_ word added to the dictionary.

This creates a situation that computer science calls a "hyper-static" name state.

This can lead to code where the same name can be used in different
definitions with no problem but it is probably NOT wise for your sanity. :)

VARIABLE X
: GETX X @ . ; \ shows the last X defined

VARIABLE X
: GET-THISX X @ . ; \ shows contents of the second X

VARIABLE X
: OhMYGOODNESS X @ . ; \ shows the contents of the third X

So it is not what you are used to perhaps but it works fine once you know how it operates.
Hope this removes your confusion.

Re: Learn forth: how forth nests words properly ?

<6a23e34e-4dc0-449c-82ee-4a6c99bd9924n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16616&group=comp.lang.forth#16616

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:22d4:: with SMTP id o20mr929742qki.90.1643963215599;
Fri, 04 Feb 2022 00:26:55 -0800 (PST)
X-Received: by 2002:ac8:59c3:: with SMTP id f3mr1204413qtf.307.1643963215453;
Fri, 04 Feb 2022 00:26:55 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 4 Feb 2022 00:26:55 -0800 (PST)
In-Reply-To: <c82076ea-f43b-4644-8ee3-e7d80b523857n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=79.224.111.239; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 79.224.111.239
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
<2022Feb2.114118@mips.complang.tuwien.ac.at> <b9ef124f-5ccf-47cd-9d0b-69a3fe46d387n@googlegroups.com>
<c82076ea-f43b-4644-8ee3-e7d80b523857n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6a23e34e-4dc0-449c-82ee-4a6c99bd9924n@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Fri, 04 Feb 2022 08:26:55 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 101
 by: minf...@arcor.de - Fri, 4 Feb 2022 08:26 UTC

Brian Fox schrieb am Freitag, 4. Februar 2022 um 03:23:27 UTC+1:
> On Wednesday, February 2, 2022 at 9:38:21 AM UTC-5, fabianor...@gmail.com wrote:
> > Em quarta-feira, 2 de fevereiro de 2022 às 07:50:05 UTC-3, Anton Ertl escreveu:
> > > "fabianor...@gmail.com" <fabianor...@gmail.com> writes:
> > > >I'm studying the forth language and I have a question about word nesting: s=
> > > >uppose I created a word "program version 1.0" and it would stay inside the =
> > > >word "info" along with other words, then I modified "program version" for s=
> > > >ome reason ( version 2.0). The case is that now version of the program is n=
> > > >ot 2.0 but 1.0 .
> > > >If I were programming defining words and one better grouped several togethe=
> > > >r soon it could become hell with a minimum of carelessness! Forgetting to r=
> > > >edefine some words.
> > > >I know that the field pointers still point to their old definitions and for=
> > > > design reasons (I believe) because it is minimalist and a lot of use in li=
> > > >mited systems it doesn't adopt garbage collection but "overwrites another d=
> > > >efinition in the dictionary" seems pretty smart for the embedded world, but=
> > > > if the code grows too large, it looks like this will give a lot of headach=
> > > >e.
> > > >So... how is forth's way of dealing with this?
> > > It's not clear if I understand what you mean, but I interpret the
> > > question as:
> > >
> > > You load new versions of a program on top of old versions, repeatedly,
> > > and wonder about the memory consumption of this approach, and how
> > > Forth deals with it.
> > >
> > > My anser to that question is that if you load the program N times, you
> > > will typically consume N times as much memory as when you load it
> > > once. There are several ways to deal with that in Forth: One is to
> > > end the current session and start a new one when you want to load a
> > > new version. Another is to forget the old program (with FORGET,
> > > MARKER, or (nonstandard, but used by some) ANEW) and then load the new
> > > one without ending the session.
> > >
> > > - anton
> > > --
> > > M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
> > > comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
> > > New standard: http://www.forth200x.org/forth200x.html
> > > EuroForth 2021: https://euro.theforth.net/2021
> > In other languages u recompile or interpreted overwrite the function(word) and move on(of course depending on the size to recompile... )
> > Forth uses a dictionary that creates another definition and does not overwrite or erase the previous one. Which ends up creating two words with the same name in the system without me realizing it.
> > As I'm new to forth I figured I shouldn't be doing things the forth way..
> Something that has not been mentioned is how the Forth dictionary is searched.
> The search starts at the last definition, in other words from the back to front.
>
> If I create:
> : WORD1 ." Hello" ;
> : WORD1 ." World ;
> : WORD1 ." WHAT?" ;
>
> Yes three words with the same name are created
> BUT! Forth can now only find the last one defined. Why?
> Because the search begins at the _ LAST_ word added to the dictionary.
>
> This creates a situation that computer science calls a "hyper-static" name state.
>
> This can lead to code where the same name can be used in different
> definitions with no problem but it is probably NOT wise for your sanity. :)
>
> VARIABLE X
> : GETX X @ . ; \ shows the last X defined
>
> VARIABLE X
> : GET-THISX X @ . ; \ shows contents of the second X
>
> VARIABLE X
> : OhMYGOODNESS X @ . ; \ shows the contents of the third X
>
> So it is not what you are used to perhaps but it works fine once you know how it operates.
> Hope this removes your confusion.

To rescue some sanity: ;-)
When those variables are in different wordlists, changing the search order
can do wonders

Re: Learn forth: how forth nests words properly ?

<ff4fbf71-ab4e-4d6f-bcb5-afa3482a95fdn@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16623&group=comp.lang.forth#16623

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:430d:: with SMTP id u13mr1673099qko.286.1643986428970;
Fri, 04 Feb 2022 06:53:48 -0800 (PST)
X-Received: by 2002:a05:620a:44d4:: with SMTP id y20mr1678223qkp.272.1643986428773;
Fri, 04 Feb 2022 06:53:48 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 4 Feb 2022 06:53:48 -0800 (PST)
In-Reply-To: <6a23e34e-4dc0-449c-82ee-4a6c99bd9924n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=168.121.177.102; posting-account=OMrK2AoAAACPu8JcOP64zhFwVmCz0fk3
NNTP-Posting-Host: 168.121.177.102
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
<2022Feb2.114118@mips.complang.tuwien.ac.at> <b9ef124f-5ccf-47cd-9d0b-69a3fe46d387n@googlegroups.com>
<c82076ea-f43b-4644-8ee3-e7d80b523857n@googlegroups.com> <6a23e34e-4dc0-449c-82ee-4a6c99bd9924n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ff4fbf71-ab4e-4d6f-bcb5-afa3482a95fdn@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: fabianor...@gmail.com (fabianor...@gmail.com)
Injection-Date: Fri, 04 Feb 2022 14:53:48 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 111
 by: fabianor...@gmail.co - Fri, 4 Feb 2022 14:53 UTC

Em sexta-feira, 4 de fevereiro de 2022 às 05:26:56 UTC-3, minf...@arcor.de escreveu:
> Brian Fox schrieb am Freitag, 4. Februar 2022 um 03:23:27 UTC+1:
> > On Wednesday, February 2, 2022 at 9:38:21 AM UTC-5, fabianor...@gmail.com wrote:
> > > Em quarta-feira, 2 de fevereiro de 2022 às 07:50:05 UTC-3, Anton Ertl escreveu:
> > > > "fabianor...@gmail.com" <fabianor...@gmail.com> writes:
> > > > >I'm studying the forth language and I have a question about word nesting: s=
> > > > >uppose I created a word "program version 1.0" and it would stay inside the =
> > > > >word "info" along with other words, then I modified "program version" for s=
> > > > >ome reason ( version 2.0). The case is that now version of the program is n=
> > > > >ot 2.0 but 1.0 .
> > > > >If I were programming defining words and one better grouped several togethe=
> > > > >r soon it could become hell with a minimum of carelessness! Forgetting to r=
> > > > >edefine some words.
> > > > >I know that the field pointers still point to their old definitions and for=
> > > > > design reasons (I believe) because it is minimalist and a lot of use in li=
> > > > >mited systems it doesn't adopt garbage collection but "overwrites another d=
> > > > >efinition in the dictionary" seems pretty smart for the embedded world, but=
> > > > > if the code grows too large, it looks like this will give a lot of headach=
> > > > >e.
> > > > >So... how is forth's way of dealing with this?
> > > > It's not clear if I understand what you mean, but I interpret the
> > > > question as:
> > > >
> > > > You load new versions of a program on top of old versions, repeatedly,
> > > > and wonder about the memory consumption of this approach, and how
> > > > Forth deals with it.
> > > >
> > > > My anser to that question is that if you load the program N times, you
> > > > will typically consume N times as much memory as when you load it
> > > > once. There are several ways to deal with that in Forth: One is to
> > > > end the current session and start a new one when you want to load a
> > > > new version. Another is to forget the old program (with FORGET,
> > > > MARKER, or (nonstandard, but used by some) ANEW) and then load the new
> > > > one without ending the session.
> > > >
> > > > - anton
> > > > --
> > > > M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
> > > > comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
> > > > New standard: http://www.forth200x.org/forth200x.html
> > > > EuroForth 2021: https://euro.theforth.net/2021
> > > In other languages u recompile or interpreted overwrite the function(word) and move on(of course depending on the size to recompile... )
> > > Forth uses a dictionary that creates another definition and does not overwrite or erase the previous one. Which ends up creating two words with the same name in the system without me realizing it.
> > > As I'm new to forth I figured I shouldn't be doing things the forth way.
> > Something that has not been mentioned is how the Forth dictionary is searched.
> > The search starts at the last definition, in other words from the back to front.
> >
> > If I create:
> > : WORD1 ." Hello" ;
> > : WORD1 ." World ;
> > : WORD1 ." WHAT?" ;
> >
> > Yes three words with the same name are created
> > BUT! Forth can now only find the last one defined. Why?
> > Because the search begins at the _ LAST_ word added to the dictionary.
> >
> > This creates a situation that computer science calls a "hyper-static" name state.
> >
> > This can lead to code where the same name can be used in different
> > definitions with no problem but it is probably NOT wise for your sanity.. :)
> >
> > VARIABLE X
> > : GETX X @ . ; \ shows the last X defined
> >
> > VARIABLE X
> > : GET-THISX X @ . ; \ shows contents of the second X
> >
> > VARIABLE X
> > : OhMYGOODNESS X @ . ; \ shows the contents of the third X
> >
> > So it is not what you are used to perhaps but it works fine once you know how it operates.
> > Hope this removes your confusion.
> To rescue some sanity: ;-)
> When those variables are in different wordlists, changing the search order
> can do wonders
I think Mr dxforth and Brian Fox only saw one of the last posts, because the problem is the exact opposite.
Mark Wills is trying to help me how I can get around this problem.

Re: Learn forth: how forth nests words properly ?

<b71a363a-71ac-415b-9744-dafe2809f694n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16626&group=comp.lang.forth#16626

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:224d:: with SMTP id c13mr2321795qvc.37.1643990630288;
Fri, 04 Feb 2022 08:03:50 -0800 (PST)
X-Received: by 2002:a05:620a:4084:: with SMTP id f4mr1887151qko.327.1643990629998;
Fri, 04 Feb 2022 08:03:49 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 4 Feb 2022 08:03:49 -0800 (PST)
In-Reply-To: <ff4fbf71-ab4e-4d6f-bcb5-afa3482a95fdn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=168.121.177.102; posting-account=OMrK2AoAAACPu8JcOP64zhFwVmCz0fk3
NNTP-Posting-Host: 168.121.177.102
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
<2022Feb2.114118@mips.complang.tuwien.ac.at> <b9ef124f-5ccf-47cd-9d0b-69a3fe46d387n@googlegroups.com>
<c82076ea-f43b-4644-8ee3-e7d80b523857n@googlegroups.com> <6a23e34e-4dc0-449c-82ee-4a6c99bd9924n@googlegroups.com>
<ff4fbf71-ab4e-4d6f-bcb5-afa3482a95fdn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b71a363a-71ac-415b-9744-dafe2809f694n@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: fabianor...@gmail.com (fabianor...@gmail.com)
Injection-Date: Fri, 04 Feb 2022 16:03:50 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 135
 by: fabianor...@gmail.co - Fri, 4 Feb 2022 16:03 UTC

Em sexta-feira, 4 de fevereiro de 2022 às 11:53:50 UTC-3, fabianor...@gmail.com escreveu:
> Em sexta-feira, 4 de fevereiro de 2022 às 05:26:56 UTC-3, minf...@arcor.de escreveu:
> > Brian Fox schrieb am Freitag, 4. Februar 2022 um 03:23:27 UTC+1:
> > > On Wednesday, February 2, 2022 at 9:38:21 AM UTC-5, fabianor...@gmail..com wrote:
> > > > Em quarta-feira, 2 de fevereiro de 2022 às 07:50:05 UTC-3, Anton Ertl escreveu:
> > > > > "fabianor...@gmail.com" <fabianor...@gmail.com> writes:
> > > > > >I'm studying the forth language and I have a question about word nesting: s=
> > > > > >uppose I created a word "program version 1.0" and it would stay inside the =
> > > > > >word "info" along with other words, then I modified "program version" for s=
> > > > > >ome reason ( version 2.0). The case is that now version of the program is n=
> > > > > >ot 2.0 but 1.0 .
> > > > > >If I were programming defining words and one better grouped several togethe=
> > > > > >r soon it could become hell with a minimum of carelessness! Forgetting to r=
> > > > > >edefine some words.
> > > > > >I know that the field pointers still point to their old definitions and for=
> > > > > > design reasons (I believe) because it is minimalist and a lot of use in li=
> > > > > >mited systems it doesn't adopt garbage collection but "overwrites another d=
> > > > > >efinition in the dictionary" seems pretty smart for the embedded world, but=
> > > > > > if the code grows too large, it looks like this will give a lot of headach=
> > > > > >e.
> > > > > >So... how is forth's way of dealing with this?
> > > > > It's not clear if I understand what you mean, but I interpret the
> > > > > question as:
> > > > >
> > > > > You load new versions of a program on top of old versions, repeatedly,
> > > > > and wonder about the memory consumption of this approach, and how
> > > > > Forth deals with it.
> > > > >
> > > > > My anser to that question is that if you load the program N times, you
> > > > > will typically consume N times as much memory as when you load it
> > > > > once. There are several ways to deal with that in Forth: One is to
> > > > > end the current session and start a new one when you want to load a
> > > > > new version. Another is to forget the old program (with FORGET,
> > > > > MARKER, or (nonstandard, but used by some) ANEW) and then load the new
> > > > > one without ending the session.
> > > > >
> > > > > - anton
> > > > > --
> > > > > M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
> > > > > comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
> > > > > New standard: http://www.forth200x.org/forth200x.html
> > > > > EuroForth 2021: https://euro.theforth.net/2021
> > > > In other languages u recompile or interpreted overwrite the function(word) and move on(of course depending on the size to recompile... )
> > > > Forth uses a dictionary that creates another definition and does not overwrite or erase the previous one. Which ends up creating two words with the same name in the system without me realizing it.
> > > > As I'm new to forth I figured I shouldn't be doing things the forth way.
> > > Something that has not been mentioned is how the Forth dictionary is searched.
> > > The search starts at the last definition, in other words from the back to front.
> > >
> > > If I create:
> > > : WORD1 ." Hello" ;
> > > : WORD1 ." World ;
> > > : WORD1 ." WHAT?" ;
> > >
> > > Yes three words with the same name are created
> > > BUT! Forth can now only find the last one defined. Why?
> > > Because the search begins at the _ LAST_ word added to the dictionary..
> > >
> > > This creates a situation that computer science calls a "hyper-static" name state.
> > >
> > > This can lead to code where the same name can be used in different
> > > definitions with no problem but it is probably NOT wise for your sanity. :)
> > >
> > > VARIABLE X
> > > : GETX X @ . ; \ shows the last X defined
> > >
> > > VARIABLE X
> > > : GET-THISX X @ . ; \ shows contents of the second X
> > >
> > > VARIABLE X
> > > : OhMYGOODNESS X @ . ; \ shows the contents of the third X
> > >
> > > So it is not what you are used to perhaps but it works fine once you know how it operates.
> > > Hope this removes your confusion.
> > To rescue some sanity: ;-)
> > When those variables are in different wordlists, changing the search order
> > can do wonders
> I think Mr dxforth and Brian Fox only saw one of the last posts, because the problem is the exact opposite.
> Mark Wills is trying to help me how I can get around this problem.
Mark Wills, yes, but it falls into the problem that dxforth mentioned, this is topdown and how software tends to change in ways you don't expect... this falls into the problem of putting "hooks" (I think it was in the book Thinking forth that I read this), trying to predict a problem that in the future doesn't exist or isn't the right way.
In a small scenario it generates discomfort and as it grows it only tends to get worse.
Imagine that you also redefined the definition you just redefined, but now you discover that it was nested in other definitions which in turn were part of others... imagine this in a legacy code that you didn't even write... hahaha hell.
One of the most natural solutions would be to have a unique identifier however it seems to me that it goes against the design of forth.
The best solution so far that seems better is to create a word that during compilation checks if it is being redefined and if so updates the definitions body (its pointer) and scans the current dictionary in search of the same name and updates them.
But what if the previous definition doesn't have enough space to update because there are too many nested definitions?
But that would entail creating a field with a pointer that points to the body of the definition then replacing it with the current one.

Re: Learn forth: how forth nests words properly ?

<f986ac4b-f011-402e-9c0b-532dda4085c4n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16627&group=comp.lang.forth#16627

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:20ee:: with SMTP id 14mr2401541qvk.38.1643990828917;
Fri, 04 Feb 2022 08:07:08 -0800 (PST)
X-Received: by 2002:a05:6214:2349:: with SMTP id hu9mr1630236qvb.16.1643990828709;
Fri, 04 Feb 2022 08:07:08 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Fri, 4 Feb 2022 08:07:08 -0800 (PST)
In-Reply-To: <ff4fbf71-ab4e-4d6f-bcb5-afa3482a95fdn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=92.40.195.183; posting-account=-Z7-HwoAAAAWOrLQDWUcFYPD8_KiaWMt
NNTP-Posting-Host: 92.40.195.183
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
<2022Feb2.114118@mips.complang.tuwien.ac.at> <b9ef124f-5ccf-47cd-9d0b-69a3fe46d387n@googlegroups.com>
<c82076ea-f43b-4644-8ee3-e7d80b523857n@googlegroups.com> <6a23e34e-4dc0-449c-82ee-4a6c99bd9924n@googlegroups.com>
<ff4fbf71-ab4e-4d6f-bcb5-afa3482a95fdn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f986ac4b-f011-402e-9c0b-532dda4085c4n@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: markwill...@gmail.com (Mark Wills)
Injection-Date: Fri, 04 Feb 2022 16:07:08 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 152
 by: Mark Wills - Fri, 4 Feb 2022 16:07 UTC

On Friday, February 4, 2022 at 2:53:50 PM UTC, fabianor...@gmail.com wrote:
> Em sexta-feira, 4 de fevereiro de 2022 às 05:26:56 UTC-3, minf...@arcor.de escreveu:
> > Brian Fox schrieb am Freitag, 4. Februar 2022 um 03:23:27 UTC+1:
> > > On Wednesday, February 2, 2022 at 9:38:21 AM UTC-5, fabianor...@gmail..com wrote:
> > > > Em quarta-feira, 2 de fevereiro de 2022 às 07:50:05 UTC-3, Anton Ertl escreveu:
> > > > > "fabianor...@gmail.com" <fabianor...@gmail.com> writes:
> > > > > >I'm studying the forth language and I have a question about word nesting: s=
> > > > > >uppose I created a word "program version 1.0" and it would stay inside the =
> > > > > >word "info" along with other words, then I modified "program version" for s=
> > > > > >ome reason ( version 2.0). The case is that now version of the program is n=
> > > > > >ot 2.0 but 1.0 .
> > > > > >If I were programming defining words and one better grouped several togethe=
> > > > > >r soon it could become hell with a minimum of carelessness! Forgetting to r=
> > > > > >edefine some words.
> > > > > >I know that the field pointers still point to their old definitions and for=
> > > > > > design reasons (I believe) because it is minimalist and a lot of use in li=
> > > > > >mited systems it doesn't adopt garbage collection but "overwrites another d=
> > > > > >efinition in the dictionary" seems pretty smart for the embedded world, but=
> > > > > > if the code grows too large, it looks like this will give a lot of headach=
> > > > > >e.
> > > > > >So... how is forth's way of dealing with this?
> > > > > It's not clear if I understand what you mean, but I interpret the
> > > > > question as:
> > > > >
> > > > > You load new versions of a program on top of old versions, repeatedly,
> > > > > and wonder about the memory consumption of this approach, and how
> > > > > Forth deals with it.
> > > > >
> > > > > My anser to that question is that if you load the program N times, you
> > > > > will typically consume N times as much memory as when you load it
> > > > > once. There are several ways to deal with that in Forth: One is to
> > > > > end the current session and start a new one when you want to load a
> > > > > new version. Another is to forget the old program (with FORGET,
> > > > > MARKER, or (nonstandard, but used by some) ANEW) and then load the new
> > > > > one without ending the session.
> > > > >
> > > > > - anton
> > > > > --
> > > > > M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
> > > > > comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
> > > > > New standard: http://www.forth200x.org/forth200x.html
> > > > > EuroForth 2021: https://euro.theforth.net/2021
> > > > In other languages u recompile or interpreted overwrite the function(word) and move on(of course depending on the size to recompile... )
> > > > Forth uses a dictionary that creates another definition and does not overwrite or erase the previous one. Which ends up creating two words with the same name in the system without me realizing it.
> > > > As I'm new to forth I figured I shouldn't be doing things the forth way.
> > > Something that has not been mentioned is how the Forth dictionary is searched.
> > > The search starts at the last definition, in other words from the back to front.
> > >
> > > If I create:
> > > : WORD1 ." Hello" ;
> > > : WORD1 ." World ;
> > > : WORD1 ." WHAT?" ;
> > >
> > > Yes three words with the same name are created
> > > BUT! Forth can now only find the last one defined. Why?
> > > Because the search begins at the _ LAST_ word added to the dictionary..
> > >
> > > This creates a situation that computer science calls a "hyper-static" name state.
> > >
> > > This can lead to code where the same name can be used in different
> > > definitions with no problem but it is probably NOT wise for your sanity. :)
> > >
> > > VARIABLE X
> > > : GETX X @ . ; \ shows the last X defined
> > >
> > > VARIABLE X
> > > : GET-THISX X @ . ; \ shows contents of the second X
> > >
> > > VARIABLE X
> > > : OhMYGOODNESS X @ . ; \ shows the contents of the third X
> > >
> > > So it is not what you are used to perhaps but it works fine once you know how it operates.
> > > Hope this removes your confusion.
> > To rescue some sanity: ;-)
> > When those variables are in different wordlists, changing the search order
> > can do wonders
> I think Mr dxforth and Brian Fox only saw one of the last posts, because the problem is the exact opposite.
> Mark Wills is trying to help me how I can get around this problem.

Here's the example from my site: ( http://turboforth.net/resources/defer-is..html )

DEFER UpDown

: CountUp ( n -- n+1) 1+ ;
: CountDown ( n -- n-1) 1- ;

: Counter ( -- )
0 BEGIN
UpDown DUP .
KEY? CASE
32 OF DROP EXIT ENDOF \ exit if space bar is pressed
ASCII U OF ['] CountUp ['] UpDown DEFER! ENDOF
ASCII D OF ['] CountDown ['] UpDown DEFER! ENDOF
ENDCASE
AGAIN ;

' CountUp IS UpDown

I think this is exactly what you are looking for, as your application doesn't need to change, but you can 'change out' the words you are working on as many times as you like, without having to re-load or re-compile the whole application - which can be annoying. It gets around the dictionary linking limitation that Brian Fox explained earlier.

Note: For your Forth, you will not need to implement DEFER or IS yourself. They will almost certainly be built into the system. My system is a 32K system so it's not built in!

KEY? may not be a thing on your system - it reads the keyboard, but doesn't wait for a key. If a key is being held down when KEY? executes, it returns the ASCII code of the key, otherwise (at least on my system) it returns -1..

Hope this helps

Mark

Re: Learn forth: how forth nests words properly ?

<stjpvf$8ar$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16630&group=comp.lang.forth#16630

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: how...@inventio.co.uk (Howerd Oakford)
Newsgroups: comp.lang.forth
Subject: Re: Learn forth: how forth nests words properly ?
Date: Fri, 4 Feb 2022 19:06:41 +0100
Organization: A noiseless patient Spider
Lines: 104
Message-ID: <stjpvf$8ar$1@dont-email.me>
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
<2022Feb2.114118@mips.complang.tuwien.ac.at>
<b9ef124f-5ccf-47cd-9d0b-69a3fe46d387n@googlegroups.com>
<c82076ea-f43b-4644-8ee3-e7d80b523857n@googlegroups.com>
<6a23e34e-4dc0-449c-82ee-4a6c99bd9924n@googlegroups.com>
<ff4fbf71-ab4e-4d6f-bcb5-afa3482a95fdn@googlegroups.com>
<b71a363a-71ac-415b-9744-dafe2809f694n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 4 Feb 2022 18:06:39 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="981436fd8b29ac6c83ef3c3fe0d19a92";
logging-data="8539"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1948SgfrDTeDkDYzXMriQ9i"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:xecUcx1G9eGkTdyl7jgZkGWNGBI=
In-Reply-To: <b71a363a-71ac-415b-9744-dafe2809f694n@googlegroups.com>
 by: Howerd Oakford - Fri, 4 Feb 2022 18:06 UTC

Am 04/02/2022 um 17:03 schrieb fabianor...@gmail.com:
> Em sexta-feira, 4 de fevereiro de 2022 às 11:53:50 UTC-3, fabianor...@gmail.com escreveu:
>> Em sexta-feira, 4 de fevereiro de 2022 às 05:26:56 UTC-3, minf...@arcor.de escreveu:
>>> Brian Fox schrieb am Freitag, 4. Februar 2022 um 03:23:27 UTC+1:
>>>> On Wednesday, February 2, 2022 at 9:38:21 AM UTC-5, fabianor...@gmail.com wrote:
>>>>> Em quarta-feira, 2 de fevereiro de 2022 às 07:50:05 UTC-3, Anton Ertl escreveu:
>>>>>> "fabianor...@gmail.com" <fabianor...@gmail.com> writes:
>>>>>>> I'm studying the forth language and I have a question about word nesting: s=
>>>>>>> uppose I created a word "program version 1.0" and it would stay inside the =
>>>>>>> word "info" along with other words, then I modified "program version" for s=
>>>>>>> ome reason ( version 2.0). The case is that now version of the program is n=
>>>>>>> ot 2.0 but 1.0 .
>>>>>>> If I were programming defining words and one better grouped several togethe=
>>>>>>> r soon it could become hell with a minimum of carelessness! Forgetting to r=
>>>>>>> edefine some words.
>>>>>>> I know that the field pointers still point to their old definitions and for=
>>>>>>> design reasons (I believe) because it is minimalist and a lot of use in li=
>>>>>>> mited systems it doesn't adopt garbage collection but "overwrites another d=
>>>>>>> efinition in the dictionary" seems pretty smart for the embedded world, but=
>>>>>>> if the code grows too large, it looks like this will give a lot of headach=
>>>>>>> e.
>>>>>>> So... how is forth's way of dealing with this?
>>>>>> It's not clear if I understand what you mean, but I interpret the
>>>>>> question as:
>>>>>>
>>>>>> You load new versions of a program on top of old versions, repeatedly,
>>>>>> and wonder about the memory consumption of this approach, and how
>>>>>> Forth deals with it.
>>>>>>
>>>>>> My anser to that question is that if you load the program N times, you
>>>>>> will typically consume N times as much memory as when you load it
>>>>>> once. There are several ways to deal with that in Forth: One is to
>>>>>> end the current session and start a new one when you want to load a
>>>>>> new version. Another is to forget the old program (with FORGET,
>>>>>> MARKER, or (nonstandard, but used by some) ANEW) and then load the new
>>>>>> one without ending the session.
>>>>>>
>>>>>> - anton
>>>>>> --
>>>>>> M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
>>>>>> comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
>>>>>> New standard: http://www.forth200x.org/forth200x.html
>>>>>> EuroForth 2021: https://euro.theforth.net/2021
>>>>> In other languages u recompile or interpreted overwrite the function(word) and move on(of course depending on the size to recompile... )
>>>>> Forth uses a dictionary that creates another definition and does not overwrite or erase the previous one. Which ends up creating two words with the same name in the system without me realizing it.
>>>>> As I'm new to forth I figured I shouldn't be doing things the forth way.
>>>> Something that has not been mentioned is how the Forth dictionary is searched.
>>>> The search starts at the last definition, in other words from the back to front.
>>>>
>>>> If I create:
>>>> : WORD1 ." Hello" ;
>>>> : WORD1 ." World ;
>>>> : WORD1 ." WHAT?" ;
>>>>
>>>> Yes three words with the same name are created
>>>> BUT! Forth can now only find the last one defined. Why?
>>>> Because the search begins at the _ LAST_ word added to the dictionary.
>>>>
>>>> This creates a situation that computer science calls a "hyper-static" name state.
>>>>
>>>> This can lead to code where the same name can be used in different
>>>> definitions with no problem but it is probably NOT wise for your sanity. :)
>>>>
>>>> VARIABLE X
>>>> : GETX X @ . ; \ shows the last X defined
>>>>
>>>> VARIABLE X
>>>> : GET-THISX X @ . ; \ shows contents of the second X
>>>>
>>>> VARIABLE X
>>>> : OhMYGOODNESS X @ . ; \ shows the contents of the third X
>>>>
>>>> So it is not what you are used to perhaps but it works fine once you know how it operates.
>>>> Hope this removes your confusion.
>>> To rescue some sanity: ;-)
>>> When those variables are in different wordlists, changing the search order
>>> can do wonders
>> I think Mr dxforth and Brian Fox only saw one of the last posts, because the problem is the exact opposite.
>> Mark Wills is trying to help me how I can get around this problem.
> Mark Wills, yes, but it falls into the problem that dxforth mentioned, this is topdown and how software tends to change in ways you don't expect... this falls into the problem of putting "hooks" (I think it was in the book Thinking forth that I read this), trying to predict a problem that in the future doesn't exist or isn't the right way.
> In a small scenario it generates discomfort and as it grows it only tends to get worse.
> Imagine that you also redefined the definition you just redefined, but now you discover that it was nested in other definitions which in turn were part of others... imagine this in a legacy code that you didn't even write... hahaha hell.
> One of the most natural solutions would be to have a unique identifier however it seems to me that it goes against the design of forth.
> The best solution so far that seems better is to create a word that during compilation checks if it is being redefined and if so updates the definitions body (its pointer) and scans the current dictionary in search of the same name and updates them.
> But what if the previous definition doesn't have enough space to update because there are too many nested definitions?
> But that would entail creating a field with a pointer that points to the body of the definition then replacing it with the current one.
Hi fabianor,

The way I avoid this type of problem is by using "empty" at the start of
a load file or load block.
This means that everything gets compiled following the order in the
source. If a word is redefined most systems give you a warning, which
you can ignore if you like.
Compilation times for a sizeable test program using swiftForth on
Windows is about 400 ms, including building an executable.

For a different aproach, Holon allows you to redefine Forth words
on-the-fly. It stores the source in a database, and compiles with some
extra space so that it can automatically recompile without shifting
everthing else around. Link : https://holonforth.com/

Cheers,
Howerd

Re: Learn forth: how forth nests words properly ?

<2022Feb4.193018@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16633&group=comp.lang.forth#16633

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Learn forth: how forth nests words properly ?
Date: Fri, 04 Feb 2022 18:30:18 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 56
Message-ID: <2022Feb4.193018@mips.complang.tuwien.ac.at>
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com> <2022Feb2.114118@mips.complang.tuwien.ac.at> <fd0576c0-90c0-463a-b23e-137f5be5593en@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="a6dc4ccf252b598774c1feb34868ddf5";
logging-data="19134"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Vwq9Mn5dmgA/gdUepCDjh"
Cancel-Lock: sha1:g4Ga7YYwGcWUrTrkk1nLt0aSCdw=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 4 Feb 2022 18:30 UTC

"fabianor...@gmail.com" <fabianorezende26@gmail.com> writes:
>example:
>: my-word word-1 word-2 word-3 ;
>if i modify word-1 i now have two word-1!

So yes, you don't modify WORD-1, you define a new WORD-1.

>The one that was redefined and th=
>e other on the old definition of my-word. Well, just reset my-word too and =
>everything goes back to what you expected.

The problem is not what I expect, the problem is what you expect. You
seem to expect that Forth behaves like Lisp or Postscript when
defining a word with the same name as an existing word. Forth does
not behave that way. As a consequence, some usages you know from
languages that behave like Lisp don't work in Forth, but OTOH, there
are usages that work in Forth, but not in Lisp, e.g.:

In gforth-fast on ARM A64 / does not report division by zero:

1 0 / . \ prints 0

Let's say I want to have a more pedantic /. In Forth I can do:

: / ( n1 n2 -- n )
dup 0= -10 and throw / ;

Now

1 0 / .

produces:

*the terminal*:4:5: error: Division by zero
1 0 >>>/<<< .
Backtrace:
*terminal*:3:18: 0 $7FB742A040 throw

>What seemed to be something trivial is going to become something I have to =
>be very careful about.
>As the program grows and I need to rename words either because I found a bu=
>g, or because I needed to update the system... whatever the reason, if a wo=
>rd inside another changes, we will have 2 words with the same name and I wo=
>uld need to remember where these words are nested.
>So I thought there must be a better way to handle this.

If you found a bug or update the system, the usual way is to start a
new session and reload the program (or alternatively, use FORGET or a
marker or ANEW to delete the program). No particular care needed.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Learn forth: how forth nests words properly ?

<2022Feb4.194413@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16634&group=comp.lang.forth#16634

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Learn forth: how forth nests words properly ?
Date: Fri, 04 Feb 2022 18:44:13 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 32
Message-ID: <2022Feb4.194413@mips.complang.tuwien.ac.at>
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com> <2022Feb2.114118@mips.complang.tuwien.ac.at> <b9ef124f-5ccf-47cd-9d0b-69a3fe46d387n@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="a6dc4ccf252b598774c1feb34868ddf5";
logging-data="19134"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ZEQEcfRcPwujjnZG5GWdT"
Cancel-Lock: sha1:TqpS71/LlrQ5iCARLtdttAQeh30=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 4 Feb 2022 18:44 UTC

"fabianor...@gmail.com" <fabianorezende26@gmail.com> writes:
>In other languages u recompile or interpreted overwrite the function(word) =
>and move on(of course depending on the size to recompile... )

Some languages behave the Lisp way, some don't. E.g. in typical
Algol-family languages defining the same name twice in a scope
produces a compiler error. In Prolog, if you define a clause with a
name, it is added to the clauses of the predicate with the same name
and arity; e.g., with SWI-Prolog:

?- [user].

|: a(1).
|: a(2).
|: <EOF> % prints "true."

?- a(X). % prints the following, where I type the ";"
X = 1 ;
X = 2.

And Forth just defines a new word with the same name.

>As I'm new to forth I figured I shouldn't be doing things the forth way.

Does not sound like the way to success with Forth to me.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Learn forth: how forth nests words properly ?

<2bf304dc-623e-4418-b551-d5f7764dc072n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16653&group=comp.lang.forth#16653

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:21e8:: with SMTP id p8mr6782165qvj.116.1644107905636;
Sat, 05 Feb 2022 16:38:25 -0800 (PST)
X-Received: by 2002:ac8:5950:: with SMTP id 16mr3976870qtz.104.1644107905413;
Sat, 05 Feb 2022 16:38:25 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sat, 5 Feb 2022 16:38:25 -0800 (PST)
In-Reply-To: <ff4fbf71-ab4e-4d6f-bcb5-afa3482a95fdn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=99.242.210.36; posting-account=2z7GawoAAADc70p5SM5AbaCyzjLblS3g
NNTP-Posting-Host: 99.242.210.36
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
<2022Feb2.114118@mips.complang.tuwien.ac.at> <b9ef124f-5ccf-47cd-9d0b-69a3fe46d387n@googlegroups.com>
<c82076ea-f43b-4644-8ee3-e7d80b523857n@googlegroups.com> <6a23e34e-4dc0-449c-82ee-4a6c99bd9924n@googlegroups.com>
<ff4fbf71-ab4e-4d6f-bcb5-afa3482a95fdn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2bf304dc-623e-4418-b551-d5f7764dc072n@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: brian....@brianfox.ca (Brian Fox)
Injection-Date: Sun, 06 Feb 2022 00:38:25 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 156
 by: Brian Fox - Sun, 6 Feb 2022 00:38 UTC

On Friday, February 4, 2022 at 9:53:50 AM UTC-5, fabianor...@gmail.com wrote:
> Em sexta-feira, 4 de fevereiro de 2022 às 05:26:56 UTC-3, minf...@arcor.de escreveu:
> > Brian Fox schrieb am Freitag, 4. Februar 2022 um 03:23:27 UTC+1:
> > > On Wednesday, February 2, 2022 at 9:38:21 AM UTC-5, fabianor...@gmail..com wrote:
> > > > Em quarta-feira, 2 de fevereiro de 2022 às 07:50:05 UTC-3, Anton Ertl escreveu:
> > > > > "fabianor...@gmail.com" <fabianor...@gmail.com> writes:
> > > > > >I'm studying the forth language and I have a question about word nesting: s=
> > > > > >uppose I created a word "program version 1.0" and it would stay inside the =
> > > > > >word "info" along with other words, then I modified "program version" for s=
> > > > > >ome reason ( version 2.0). The case is that now version of the program is n=
> > > > > >ot 2.0 but 1.0 .
> > > > > >If I were programming defining words and one better grouped several togethe=
> > > > > >r soon it could become hell with a minimum of carelessness! Forgetting to r=
> > > > > >edefine some words.
> > > > > >I know that the field pointers still point to their old definitions and for=
> > > > > > design reasons (I believe) because it is minimalist and a lot of use in li=
> > > > > >mited systems it doesn't adopt garbage collection but "overwrites another d=
> > > > > >efinition in the dictionary" seems pretty smart for the embedded world, but=
> > > > > > if the code grows too large, it looks like this will give a lot of headach=
> > > > > >e.
> > > > > >So... how is forth's way of dealing with this?
> > > > > It's not clear if I understand what you mean, but I interpret the
> > > > > question as:
> > > > >
> > > > > You load new versions of a program on top of old versions, repeatedly,
> > > > > and wonder about the memory consumption of this approach, and how
> > > > > Forth deals with it.
> > > > >
> > > > > My anser to that question is that if you load the program N times, you
> > > > > will typically consume N times as much memory as when you load it
> > > > > once. There are several ways to deal with that in Forth: One is to
> > > > > end the current session and start a new one when you want to load a
> > > > > new version. Another is to forget the old program (with FORGET,
> > > > > MARKER, or (nonstandard, but used by some) ANEW) and then load the new
> > > > > one without ending the session.
> > > > >
> > > > > - anton
> > > > > --
> > > > > M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
> > > > > comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
> > > > > New standard: http://www.forth200x.org/forth200x.html
> > > > > EuroForth 2021: https://euro.theforth.net/2021
> > > > In other languages u recompile or interpreted overwrite the function(word) and move on(of course depending on the size to recompile... )
> > > > Forth uses a dictionary that creates another definition and does not overwrite or erase the previous one. Which ends up creating two words with the same name in the system without me realizing it.
> > > > As I'm new to forth I figured I shouldn't be doing things the forth way.
> > > Something that has not been mentioned is how the Forth dictionary is searched.
> > > The search starts at the last definition, in other words from the back to front.
> > >
> > > If I create:
> > > : WORD1 ." Hello" ;
> > > : WORD1 ." World ;
> > > : WORD1 ." WHAT?" ;
> > >
> > > Yes three words with the same name are created
> > > BUT! Forth can now only find the last one defined. Why?
> > > Because the search begins at the _ LAST_ word added to the dictionary..
> > >
> > > This creates a situation that computer science calls a "hyper-static" name state.
> > >
> > > This can lead to code where the same name can be used in different
> > > definitions with no problem but it is probably NOT wise for your sanity. :)
> > >
> > > VARIABLE X
> > > : GETX X @ . ; \ shows the last X defined
> > >
> > > VARIABLE X
> > > : GET-THISX X @ . ; \ shows contents of the second X
> > >
> > > VARIABLE X
> > > : OhMYGOODNESS X @ . ; \ shows the contents of the third X
> > >
> > > So it is not what you are used to perhaps but it works fine once you know how it operates.
> > > Hope this removes your confusion.
> > To rescue some sanity: ;-)
> > When those variables are in different wordlists, changing the search order
> > can do wonders
> I think Mr dxforth and Brian Fox only saw one of the last posts, because the problem is the exact opposite.
> Mark Wills is trying to help me how I can get around this problem.

Nope.
I read all the posts.

It seems to me that you have not understood how Forth is used to develop an application.
As long as you continue to see it like another language you can't really move forward with it.
It's closer to a macro-assembler for a two stack machine than it is to other HLLs.

DEFER words are great but they have specific purposes and that does not mean making
everything in your program deferred. If this is the only solution to your problems then your
Forth program is wrong IHMO.

Forth development proceeds by creating some words you need for your application
and you re-compile them until they are error free. You test them at the command line or
with embedded test code as you prefer.

Put that working code in a file and INCLUDE that file at the top of your application.

Repeat that process with the next set of support routines until you have all your
intermediate code complete and tested.
Now you write the final application file which INCLUDEs all the support files
and you write the final application using those words.

If you have a lot of internal stuff that needs changing the application was
never finished. Fix the problems and re-compile it all.
It only takes seconds with a good Forth system.

Some Forth applications keep parts of the program as Text that is compiled on
demand because it is fast enough to do that.

Re: Learn forth: how forth nests words properly ?

<d10c1e52-4923-4409-bd0c-4e1e5e7a39e3n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=16654&group=comp.lang.forth#16654

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:665:: with SMTP id a5mr3185976qkh.500.1644110497851;
Sat, 05 Feb 2022 17:21:37 -0800 (PST)
X-Received: by 2002:a05:620a:4084:: with SMTP id f4mr3237307qko.327.1644110497660;
Sat, 05 Feb 2022 17:21:37 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sat, 5 Feb 2022 17:21:37 -0800 (PST)
In-Reply-To: <2bf304dc-623e-4418-b551-d5f7764dc072n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=168.121.177.102; posting-account=OMrK2AoAAACPu8JcOP64zhFwVmCz0fk3
NNTP-Posting-Host: 168.121.177.102
References: <7d908d30-8439-4926-a0c3-47e802cbb1b0n@googlegroups.com>
<2022Feb2.114118@mips.complang.tuwien.ac.at> <b9ef124f-5ccf-47cd-9d0b-69a3fe46d387n@googlegroups.com>
<c82076ea-f43b-4644-8ee3-e7d80b523857n@googlegroups.com> <6a23e34e-4dc0-449c-82ee-4a6c99bd9924n@googlegroups.com>
<ff4fbf71-ab4e-4d6f-bcb5-afa3482a95fdn@googlegroups.com> <2bf304dc-623e-4418-b551-d5f7764dc072n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d10c1e52-4923-4409-bd0c-4e1e5e7a39e3n@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: fabianor...@gmail.com (fabianor...@gmail.com)
Injection-Date: Sun, 06 Feb 2022 01:21:37 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 170
 by: fabianor...@gmail.co - Sun, 6 Feb 2022 01:21 UTC

Em sábado, 5 de fevereiro de 2022 às 21:38:26 UTC-3, Brian Fox escreveu:
> On Friday, February 4, 2022 at 9:53:50 AM UTC-5, fabianor...@gmail.com wrote:
> > Em sexta-feira, 4 de fevereiro de 2022 às 05:26:56 UTC-3, minf...@arcor.de escreveu:
> > > Brian Fox schrieb am Freitag, 4. Februar 2022 um 03:23:27 UTC+1:
> > > > On Wednesday, February 2, 2022 at 9:38:21 AM UTC-5, fabianor...@gmail.com wrote:
> > > > > Em quarta-feira, 2 de fevereiro de 2022 às 07:50:05 UTC-3, Anton Ertl escreveu:
> > > > > > "fabianor...@gmail.com" <fabianor...@gmail.com> writes:
> > > > > > >I'm studying the forth language and I have a question about word nesting: s=
> > > > > > >uppose I created a word "program version 1.0" and it would stay inside the =
> > > > > > >word "info" along with other words, then I modified "program version" for s=
> > > > > > >ome reason ( version 2.0). The case is that now version of the program is n=
> > > > > > >ot 2.0 but 1.0 .
> > > > > > >If I were programming defining words and one better grouped several togethe=
> > > > > > >r soon it could become hell with a minimum of carelessness! Forgetting to r=
> > > > > > >edefine some words.
> > > > > > >I know that the field pointers still point to their old definitions and for=
> > > > > > > design reasons (I believe) because it is minimalist and a lot of use in li=
> > > > > > >mited systems it doesn't adopt garbage collection but "overwrites another d=
> > > > > > >efinition in the dictionary" seems pretty smart for the embedded world, but=
> > > > > > > if the code grows too large, it looks like this will give a lot of headach=
> > > > > > >e.
> > > > > > >So... how is forth's way of dealing with this?
> > > > > > It's not clear if I understand what you mean, but I interpret the
> > > > > > question as:
> > > > > >
> > > > > > You load new versions of a program on top of old versions, repeatedly,
> > > > > > and wonder about the memory consumption of this approach, and how
> > > > > > Forth deals with it.
> > > > > >
> > > > > > My anser to that question is that if you load the program N times, you
> > > > > > will typically consume N times as much memory as when you load it
> > > > > > once. There are several ways to deal with that in Forth: One is to
> > > > > > end the current session and start a new one when you want to load a
> > > > > > new version. Another is to forget the old program (with FORGET,
> > > > > > MARKER, or (nonstandard, but used by some) ANEW) and then load the new
> > > > > > one without ending the session.
> > > > > >
> > > > > > - anton
> > > > > > --
> > > > > > M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
> > > > > > comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
> > > > > > New standard: http://www.forth200x.org/forth200x.html
> > > > > > EuroForth 2021: https://euro.theforth.net/2021
> > > > > In other languages u recompile or interpreted overwrite the function(word) and move on(of course depending on the size to recompile... )
> > > > > Forth uses a dictionary that creates another definition and does not overwrite or erase the previous one. Which ends up creating two words with the same name in the system without me realizing it.
> > > > > As I'm new to forth I figured I shouldn't be doing things the forth way.
> > > > Something that has not been mentioned is how the Forth dictionary is searched.
> > > > The search starts at the last definition, in other words from the back to front.
> > > >
> > > > If I create:
> > > > : WORD1 ." Hello" ;
> > > > : WORD1 ." World ;
> > > > : WORD1 ." WHAT?" ;
> > > >
> > > > Yes three words with the same name are created
> > > > BUT! Forth can now only find the last one defined. Why?
> > > > Because the search begins at the _ LAST_ word added to the dictionary.
> > > >
> > > > This creates a situation that computer science calls a "hyper-static" name state.
> > > >
> > > > This can lead to code where the same name can be used in different
> > > > definitions with no problem but it is probably NOT wise for your sanity. :)
> > > >
> > > > VARIABLE X
> > > > : GETX X @ . ; \ shows the last X defined
> > > >
> > > > VARIABLE X
> > > > : GET-THISX X @ . ; \ shows contents of the second X
> > > >
> > > > VARIABLE X
> > > > : OhMYGOODNESS X @ . ; \ shows the contents of the third X
> > > >
> > > > So it is not what you are used to perhaps but it works fine once you know how it operates.
> > > > Hope this removes your confusion.
> > > To rescue some sanity: ;-)
> > > When those variables are in different wordlists, changing the search order
> > > can do wonders
> > I think Mr dxforth and Brian Fox only saw one of the last posts, because the problem is the exact opposite.
> > Mark Wills is trying to help me how I can get around this problem.
> Nope.
> I read all the posts.
>
> It seems to me that you have not understood how Forth is used to develop an application.
> As long as you continue to see it like another language you can't really move forward with it.
> It's closer to a macro-assembler for a two stack machine than it is to other HLLs.
>
> DEFER words are great but they have specific purposes and that does not mean making
> everything in your program deferred. If this is the only solution to your problems then your
> Forth program is wrong IHMO.
>
> Forth development proceeds by creating some words you need for your application
> and you re-compile them until they are error free. You test them at the command line or
> with embedded test code as you prefer.
>
> Put that working code in a file and INCLUDE that file at the top of your application.
>
> Repeat that process with the next set of support routines until you have all your
> intermediate code complete and tested.
> Now you write the final application file which INCLUDEs all the support files
> and you write the final application using those words.
>
> If you have a lot of internal stuff that needs changing the application was
> never finished. Fix the problems and re-compile it all.
> It only takes seconds with a good Forth system.
>
> Some Forth applications keep parts of the program as Text that is compiled on
> demand because it is fast enough to do that.
hello Howard! I didn't understand how "empty" really works, could you explain it better?
From what little I understand she somehow warns me of the changes. That the gforth I'm using together with win32forth for study already does.
I just found that re-defining words leads a beginner to silly stumbles and becomes a worry and a lot of work as the program grows and changes. So I thought I must be doing it in a bad way because I'm still inexperienced.
So I made this post.
I saw the link about holonforth, interesting, it seems to me that it does not suffer from this problem and has a navigation system with many subdivisions of the code. Just the script that didn't look like a "common" forth.
Looks like sqliteforth haha interesting.

Pages:12
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor