Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #45670

Re: How do you remember the stack?

Newsgroups comp.lang.forth
Date 2016-02-22 01:46 -0800
References <07ab86b1-3681-47c0-80ea-d7bd908925e7@googlegroups.com>
Message-ID <e5dd3eb0-9bb7-4946-81a5-e908aefaca86@googlegroups.com> (permalink)
Subject Re: How do you remember the stack?
From humptydumpty <ouatubi@gmail.com>

Show all headers | View raw


On Friday, February 12, 2016 at 11:57:08 PM UTC+2, lahe...@gmail.com wrote:
> When I'm reading forth code, I have to work hard to remember the contents of the stack. Especially when a word is more than a few subwords long, or contains words whose stack effects I have to go and look up, I am likely to forget what the stack looks like at the point I was just at. So I have to backtrack to a previous known stack state, and recover the context by reading word by word.
> 
> One thing I do is mentally "say" the contents of the stack after every word: "a b c...b c a...c a..." etc. This seems to help my memory. But I sometimes find I'm using so much attention remembering the stack that I don't have as much short-term memory left over as I would like for understanding the program itself.
> 
> Part of this is that I'm still pretty new, but I am wondering if you have any similar experiences or strategies to share.

Hi!
Sometime ago I made a compiling from clf (mostly from Wil Baden):
BEGIN QUOTES
---
Programming style is not just layout.
Here are six desirable qualities of program style that I got from 
someone in 1986.

Economy.     Avoidance of superfluous items in a program.

Modularity.  Breaking up lengthy or complex passages into subprograms.

Simplicity.  Using a simple or straightforward method.

Structure.   Writing an orderly or well-organized program.

Documentation.  Effective use of comments.

Layout.      Effective use of space -- horizontal and vertical.

These are neither mutually exclusive nor complete, but they do provide 
a check-list for analyzing programming style.  Your evaluation of 
these qualities will vary over time.

The last quality, Layout, is the one that gets almost all the attention 
in Forth style notes.  It is the quality that has least to do with the 
meaning of a program.  

My suggestions for Forth layout are:

Do Show, Do Tell, Be Straight, Be Narrow, Don't Mumble, Don't Shout.

Do Show.       Show logic by phrasing, indentation, and alignment.

Do Tell.       Tell what's on the stack for every line.

Be Straight.   Minimize re-arranging elements on the stack.

Be Narrow.     Don't put many or unrelated items on a line.

Don't Mumble.  Avoid abbreviations and special characters in identifiers.

Don't Shout or Whisper.  Don't use all caps or all lowercase.


Telling what's on the stack _for_ every line is not _on_ every line.
When the stack state for the beginning of the next line is the same 
as in the preceding stack indicator it doesn't need repeating.

I use one graphic word for every cell on the stack.  `.` is used for 
a cell that doesn't need a name.  For instance, the stack effect for 
`D+` could be ( a . b . -- c . )

`.`s at the beginning of a stack stack is used for cells that don't 
participate until a later stack indicator.


		| Stack effect	| Upper-Case	| Extra spaces after
----------------+---------------+---------------+-------------------
STANDARD WORDS	|		| ALL		| see next rows
Nouns		| -- n ..	| First		| none
verbs		| .. m --	| none		| 1
adjectives	| .. m -- n ..	| none		| none
Interjections	| -- 		| First		| 1


(
--
Wil Baden   Costa Mesa, California   WilBaden@Netcom.com
)
---
END-QUOTES

That table I made myself to have it concise.

Enjoying Forth,
humptydumpty

Back to comp.lang.forth | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

How do you remember the stack? laheadle@gmail.com - 2016-02-12 13:57 -0800
  Re: How do you remember the stack? Paul Rubin <no.email@nospam.invalid> - 2016-02-12 14:08 -0800
    Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-02-16 13:35 +1100
      Re: How do you remember the stack? Julian Fondren <julian.fondren@gmail.com> - 2016-02-15 19:28 -0800
      Re: How do you remember the stack? Whammo <sidciavic@gmail.com> - 2016-02-15 19:54 -0800
      Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-16 07:28 +0000
        Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-02-15 22:03 -1000
          Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-16 13:30 +0000
            Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-02-16 08:20 -1000
              Re: How do you remember the stack? dunno <dunno@dunno.dunno> - 2016-02-16 20:48 +0000
              Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-17 15:42 +0000
          Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-02-18 18:48 +1100
            Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-02-18 12:27 -0800
              Re: How do you remember the stack? Julian Fondren <julian.fondren@gmail.com> - 2016-02-18 14:53 -0800
                Re: How do you remember the stack? Julian Fondren <julian.fondren@gmail.com> - 2016-02-18 15:18 -0800
              Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-02-21 13:32 +1100
                Re: How do you remember the stack? Chris Curl <ccurl609@gmail.com> - 2016-02-20 20:57 -0800
                Re: How do you remember the stack? Ron Aaron <rambamist@gmail.com> - 2016-02-21 07:23 +0200
                Re: How do you remember the stack? Chris Curl <ccurl609@gmail.com> - 2016-02-21 08:54 -0800
                Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-02-21 22:05 -0800
                Re: How do you remember the stack? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-02-22 16:20 +0100
                Re: How do you remember the stack? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-02-22 09:47 -0600
                Re: How do you remember the stack? Whammo <sidciavic@gmail.com> - 2016-02-23 16:51 -0800
                Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-02-28 15:22 +1100
                Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-02-27 21:30 -0800
                Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-02-27 21:33 -0800
                Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-02-27 21:39 -1000
                Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-02-29 13:47 +1100
                Re: How do you remember the stack? Paul Rubin <no.email@nospam.invalid> - 2016-02-28 19:02 -0800
                Re: How do you remember the stack? Julian Fondren <julian.fondren@gmail.com> - 2016-02-28 22:26 -0800
                Re: How do you remember the stack? Paul Rubin <no.email@nospam.invalid> - 2016-02-28 22:37 -0800
                Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-02-28 19:11 -0800
                Re: How do you remember the stack? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-02-29 11:55 -0600
                Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-02-29 19:30 -1000
                Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-03-02 00:49 +1100
                Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-03-01 13:50 -1000
                Re: How do you remember the stack? Paul Rubin <no.email@nospam.invalid> - 2016-03-01 16:49 -0800
                Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-03-01 18:04 -0800
                Re: How do you remember the stack? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-03-02 02:53 -0600
                Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-03-02 09:57 +0000
                Re: How do you remember the stack? Pablo Hugo Reda <pabloreda@gmail.com> - 2016-03-02 03:21 -0800
                Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-03-02 11:49 +0000
                Re: How do you remember the stack? Pablo Hugo Reda <pabloreda@gmail.com> - 2016-03-02 04:23 -0800
                Re: How do you remember the stack? stephen@mpeforth.com (Stephen Pelc) - 2016-03-02 18:32 +0000
                Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-03-02 18:41 +0000
                Re: How do you remember the stack? stephen@mpeforth.com (Stephen Pelc) - 2016-03-02 20:36 +0000
                Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-03-03 07:38 +0000
                Re: How do you remember the stack? stephen@mpeforth.com (Stephen Pelc) - 2016-03-03 09:26 +0000
                Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-03-03 11:15 +0000
                Re: How do you remember the stack? stephen@mpeforth.com (Stephen Pelc) - 2016-03-03 15:35 +0000
                Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-03-03 15:56 +0000
                Re: How do you remember the stack? stephen@mpeforth.com (Stephen Pelc) - 2016-03-03 17:04 +0000
                Re: How do you remember the stack? Whammo <sidciavic@gmail.com> - 2016-03-01 19:29 -0800
                Re: How do you remember the stack? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-02-28 18:52 +0000
                Re: How do you remember the stack? Whammo <sidciavic@gmail.com> - 2016-02-28 13:30 -0800
                Re: How do you remember the stack? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-02-29 07:55 +0100
                Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-02-29 19:34 -1000
                Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-03-01 20:40 -0800
                Re: How do you remember the stack? Unknown <dog@gmail.com> - 2016-06-02 05:46 +0000
                Re: How do you remember the stack? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-06-02 08:48 +0200
                Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-06-02 00:17 -0700
                Re: How do you remember the stack? Michael Barry <barrym95838@yahoo.com> - 2016-06-02 19:48 -0700
                Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-06-02 20:34 -0700
                Re: How do you remember the stack? "WJ" <w_a_x_man@yahoo.com> - 2016-02-22 19:23 +0000
                Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-02-25 20:31 +1100
                Re: How do you remember the stack? Julian Fondren <julian.fondren@gmail.com> - 2016-02-25 07:44 -0800
                Re: How do you remember the stack? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-02-25 20:22 +0100
                Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-02-28 13:43 +1100
                Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-02-27 21:43 -1000
                Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-28 14:53 +0000
                Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-02-28 15:27 -0800
                Re: How do you remember the stack? humptydumpty <ouatubi@gmail.com> - 2016-06-02 02:02 -0700
                Re: How do you remember the stack? JennyB <jennybrien@googlemail.com> - 2016-06-03 05:57 -0700
      Re: How do you remember the stack? Bernd Paysan <bernd.paysan@gmx.de> - 2016-03-01 16:38 +0000
  Re: How do you remember the stack? Chris Curl <ccurl609@gmail.com> - 2016-02-12 16:31 -0800
  Re: How do you remember the stack? Whammo <sidciavic@gmail.com> - 2016-02-12 17:31 -0800
  Re: How do you remember the stack? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-02-13 08:03 +0100
  Re: How do you remember the stack? dunno <dunno@dunno.dunno> - 2016-02-13 08:06 +0000
    Re: How do you remember the stack? minforth@arcor.de - 2016-02-13 01:50 -0800
      Re: How do you remember the stack? mhx@iae.nl - 2016-02-13 03:22 -0800
        Re: How do you remember the stack? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-02-13 17:09 +0000
      Re: How do you remember the stack? mhx@iae.nl - 2016-02-13 03:39 -0800
      Re: How do you remember the stack? mhx@iae.nl - 2016-02-13 03:42 -0800
      Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-13 11:27 +0000
        Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-13 12:33 +0000
          Re: How do you remember the stack? minforth@arcor.de - 2016-02-15 01:05 -0800
      Re: How do you remember the stack? dunno <dunno@dunno.dunno> - 2016-02-14 19:34 +0000
  Re: How do you remember the stack? Julian Fondren <julian.fondren@gmail.com> - 2016-02-13 06:43 -0800
    Re: How do you remember the stack? minforth@arcor.de - 2016-02-15 01:22 -0800
      Re: How do you remember the stack? dunno <dunno@dunno.dunno> - 2016-02-15 09:48 +0000
      Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-15 09:53 +0000
        Re: How do you remember the stack? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-02-15 11:26 +0000
          Re: How do you remember the stack? minforth@arcor.de - 2016-02-15 04:53 -0800
            Re: How do you remember the stack? dunno <dunno@dunno.dunno> - 2016-02-15 17:06 +0000
              Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-16 14:57 +0000
          Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-16 14:14 +0000
      Re: How do you remember the stack? Ron Aaron <rambamist@gmail.com> - 2016-02-15 12:31 +0200
      Re: How do you remember the stack? Jan Coombs <jenfhaomndgfwutc@murmic.plus.com> - 2016-02-18 22:53 +0000
  Re: How do you remember the stack? Doug Hoffman <glidedog@gmail.com> - 2016-02-13 10:51 -0500
  Re: How do you remember the stack? "HAA" <someone@microsoft.com> - 2016-02-14 10:18 +1100
  Re: How do you remember the stack? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-02-14 04:21 -0600
  Re: How do you remember the stack? Whammo <sidciavic@gmail.com> - 2016-02-20 14:36 -0800
    Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-21 16:35 +0000
      Re: How do you remember the stack? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-02-21 18:34 +0000
        Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-22 09:52 +0000
          Re: How do you remember the stack? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-02-22 13:07 +0000
            Re: How do you remember the stack? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-22 15:41 +0000
              Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-02-22 08:24 -1000
            Re: How do you remember the stack? "Elizabeth D. Rather" <erather@forth.com> - 2016-02-22 08:21 -1000
              Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-02-22 17:51 -0800
                Re: How do you remember the stack? hughaguilar96@gmail.com - 2016-02-22 18:15 -0800
                Re: How do you remember the stack? "WJ" <w_a_x_man@yahoo.com> - 2016-02-29 06:20 +0000
                Re: How do you remember the stack? "WJ" <w_a_x_man@yahoo.com> - 2016-03-02 20:42 +0000
                Re: How do you remember the stack? "WJ" <w_a_x_man@yahoo.com> - 2016-06-02 20:13 +0000
  Re: How do you remember the stack? humptydumpty <ouatubi@gmail.com> - 2016-02-22 01:46 -0800

csiph-web