Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

To invent, you need a good imagination and a pile of junk. -- Thomas Edison


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

Re: Learn forth: how forth nests words properly ?

<ca6e9ec5-840d-426e-96c7-76963778af58n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:c68:: with SMTP id t8mr7064073qvj.39.1644127556289;
Sat, 05 Feb 2022 22:05:56 -0800 (PST)
X-Received: by 2002:a05:622a:646:: with SMTP id a6mr4365500qtb.77.1644127554995;
Sat, 05 Feb 2022 22:05:54 -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 22:05:54 -0800 (PST)
In-Reply-To: <d10c1e52-4923-4409-bd0c-4e1e5e7a39e3n@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>
<d10c1e52-4923-4409-bd0c-4e1e5e7a39e3n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ca6e9ec5-840d-426e-96c7-76963778af58n@googlegroups.com>
Subject: Re: Learn forth: how forth nests words properly ?
From: fabianor...@gmail.com (fabianor...@gmail.com)
Injection-Date: Sun, 06 Feb 2022 06:05:56 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 192
 by: fabianor...@gmail.co - Sun, 6 Feb 2022 06:05 UTC

Em sábado, 5 de fevereiro de 2022 às 22:21:38 UTC-3, fabianor...@gmail.com escreveu:
> 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.
Hi Brian fox, u are right, i still don't know how the forth system works.
Yes the words defer are not for that and that's what I was talking about with mark wills.
Some software doesn't need to change but others change constantly, a bug found, a new feature, an update from a legacy system or for any reason and even (happens a lot on the web) a software grows so much that the client and the software company make it become "PARTNERS".
I don't even need to go that far, see how many people depend on third party api and libs and even a driver can be updated so subject to continuous change.
Forth seems to be very good for rapid prototyping! build, test, change quickly and redo from scratch.
The lack of a unique identifier or some way around it in order to create nests at will is unnecessarily limiting.
As I commented above creating a link to the body of the definition and on redefining it discards it and the link points to the new definition and sweeping the dictionary behind other definitions where it was nested as well and updating the body of the definitions (a way I thought to resolve this).

SubjectRepliesAuthor
o Learn forth: how forth nests words properly ?

By: fabianor...@gmail.co on Wed, 2 Feb 2022

33fabianor...@gmail.com
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor