Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.forth    |    Forth programmers eat a lot of Bratwurst    |    117,927 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 116,713 of 117,927    |
|    Hans Bezemer to Buzz McCool    |
|    Re: Avoid treating the stack as an array    |
|    07 Sep 24 14:40:41    |
      From: the.beez.speaks@gmail.com              On 06-09-2024 23:03, Buzz McCool wrote:       > On 9/5/2024 8:18 AM, Hans Bezemer wrote:       >       >> Given that the area of the circle doesn't change - why recalculate       >> that every time?       >       > Excellent observation.       >       > Would you have any videos talking about Forth locals? You and dxf are       > far more adept at stack manipulations than I. I'm thinking I can get a       > word up and working with locals and then convert to manual stack       > manipulations afterwards if necessary.       Oh, I talk a lot about locals: don't use them. The point is: you have       random access to locals. So I doubt very much it will help you to       uncover a smart way to do it without them. Basically any non-Forth       Algol-like language will do the job.              And that's in essence you I am opposed to them. It takes out what makes       Forth unique - and the way thinking of Forth unique.              > When is it necessary? dxf showed a word w/o locals to have ~%30 fewer       > instructions than a word with locals. Is that a common occurrence?              I can't really tell. In 4tH (my own implementation) the use of locals       requires an external library - so it always consumes more instructions.       It also heavily depends on the style and the skill of the programmer. If       you're a newbie doing a lot of stack acrobatics, I doubt it.              What bothers me most technologically is that parameters flow through the       stack undisturbed. You break that paradigm when using locals. With       locals you *HAVE TO* create some kind of stack frame that you have to       destroy when you exit.              Needless to say this copying, releasing and stuff takes time. Even when       you don't use locals. In all honesty I must state that this overhead is       not always translated to a diminished performance - at least not in the       tests I did.              ****       TL;DR my objections are mostly based on pure architectural arguments,       rather than practicality. I also don't like Python, PHP and Perl for       those very same reasons - one because I think its paradigms are       fundamentally flawed, the second and third because of their "have we       thrown in the kitchen sink yet" mentality.              I don't think there will ever be a "Back&Forth" episode on locals -       frankly, because - apart from some demonstrations - there is only one       single, ported program that uses locals in my repository. How can you       teach if you never used them yourself?       ****              Note that 4tH features R@, R'@ and R"@ which can server very       conveniently as "local variables" - provided you leave the Return Stack       alone. I learned that trick from the programmer of the FIG editor.              See:       https://sourceforge.net/p/forth-4th/code/HEAD/tree/trunk/4th.src       lib/gcircle.4th       for a nice example of that one.              Hans Bezemer              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca