• Interactive stack effect lookup

    From Van Kichline@21:1/5 to All on Mon Mar 13 16:44:41 2023
    I am learning Forth and switch contexts often to look up word definitions to check the parameters.
    I am considering writing a word "se" for Stack-Effects. Typing "se word" would respond with a stack effect comment from a list which I assume I'd curate.
    A good design would allow me to specify the dialect in use as well as custom lists, but I plan to start with a usable subset consisting of just gForth words.
    Before I begin, I'd like to ask if this has this already been done (better than I am likely to do it.) I would still do my own, but seeing a good design would be instructive.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From NN@21:1/5 to Van Kichline on Mon Mar 13 17:03:26 2023
    On Monday, 13 March 2023 at 23:44:43 UTC, Van Kichline wrote:
    I am learning Forth and switch contexts often to look up word definitions to check the parameters.
    I am considering writing a word "se" for Stack-Effects. Typing "se word" would respond with a stack effect comment from a list which I assume I'd curate.
    A good design would allow me to specify the dialect in use as well as custom lists, but I plan to start with a usable subset consisting of just gForth words.
    Before I begin, I'd like to ask if this has this already been done (better than I am likely to do it.) I would still do my own, but seeing a good design would be instructive.


    First, remembering stack parameters becomes easier with practice.

    Second, you could also write a quick cheat-sheet. But once you know
    the core-wordset off by heart you will rarely need it.

    Third, for words you define yourself.... stack effects are handy when
    you come back a year later to examine the code. For this you need
    to write lots of 'relevent' comments.

    I dont think I have ever seen such a word "se word" but I will leave that
    for others to comment on.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dxforth@21:1/5 to All on Tue Mar 14 12:13:21 2023
    On 14/03/2023 11:03 am, NN wrote:
    On Monday, 13 March 2023 at 23:44:43 UTC, Van Kichline wrote:
    I am learning Forth and switch contexts often to look up word definitions to check the parameters.
    I am considering writing a word "se" for Stack-Effects. Typing "se word" would respond with a stack effect comment from a list which I assume I'd curate.
    A good design would allow me to specify the dialect in use as well as custom lists, but I plan to start with a usable subset consisting of just gForth words.
    Before I begin, I'd like to ask if this has this already been done (better than I am likely to do it.) I would still do my own, but seeing a good design would be instructive.


    First, remembering stack parameters becomes easier with practice.

    Second, you could also write a quick cheat-sheet. But once you know
    the core-wordset off by heart you will rarely need it.

    Third, for words you define yourself.... stack effects are handy when
    you come back a year later to examine the code. For this you need
    to write lots of 'relevent' comments.

    I dont think I have ever seen such a word "se word" but I will leave that
    for others to comment on.

    For 'standard' words I use a html cheat sheet someone created many years ago (sorry, I forget who).

    https://pastebin.com/9596eaey

    name it QUICK.HTM

    Unpack html files from dpans6v3_3.zip:

    https://wiki.forth-ev.de/doku.php/words:ans_forth

    into folder of your choice and copy QUICK.HTM there. Create a desktop
    shortcut to QUICK.HTM and you're good to go.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@arcor.de@21:1/5 to Van Kichline on Tue Mar 14 00:22:17 2023
    Van Kichline schrieb am Dienstag, 14. März 2023 um 00:44:43 UTC+1:
    I am learning Forth and switch contexts often to look up word definitions to check the parameters.
    I am considering writing a word "se" for Stack-Effects. Typing "se word" would respond with a stack effect comment from a list which I assume I'd curate.
    A good design would allow me to specify the dialect in use as well as custom lists, but I plan to start with a usable subset consisting of just gForth words.
    Before I begin, I'd like to ask if this has this already been done (better than I am likely to do it.) I would still do my own, but seeing a good design would be instructive.

    Try
    LOCATE <wordname> to display the source
    or
    SEE <wordname> to display the compiled code.

    Stack effects are in properly done source code or in the documentation.

    Anyhow for beginners visual feedback and an integrated work environment is very helpful.
    I should mention
    https://sourceforge.net/projects/win32forth/

    Once you're more familiar, switch to a system that suits your application domain better.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to Van Kichline on Tue Mar 14 08:35:50 2023
    Van Kichline <vkichline@gmail.com> writes:
    I am considering writing a word "se" for Stack-Effects. Typing "se word" would respond with a stack effect comment from a list which I assume I'd curate.
    A good design would allow me to specify the dialect in use as well as custom lists, but I plan to start with a usable subset consisting of just gForth words.

    In the development version of Gforth you can type "help word" and you
    get the documentation for the word if it is documented, or the source
    code of the word otherwise. Both include the stack effect.

    E.g., "help word" outputs:

    |doc/gforth.txt:8641
    |'word' ( char "<chars>ccc<char>-- c-addr ) core "word"
    | Skip leading delimiters. Parse ccc, delimited by char, in the parse
    |area. c-addr is the address of a transient region containing the parsed |string in counted-string format. If the parse area was empty or
    |contained no characters other than delimiters, the resulting string has
    |zero length. A program may replace characters within the counted
    |string. OBSOLESCENT: the counted string has a trailing space that is
    |not included in its length.

    while "help .word" outputs:

    |No documentation for .word, LOCATEing source
    |kernel/tools.fs:111
    |
    |Defer word-colorize ' noop is word-colorize
    |
    |: .word ( n nt -- n' )
    | dup >r name>string tuck 2>r
    | 1+ tuck + dup cols >= IF cr drop ELSE nip THEN
    | 2r> r> word-colorize drop type space default-color ;
    |
    |: wordlist-words ( wid -- ) \ gforth
    | \G Display the contents of the wordlist wid.
    | 0 swap cr ['] .word map-wordlist drop ;
    |
    |: words ( -- ) \ tools
    | \G ** this will not get annotated. See other defn in search.fs .. **
    | \G It does not work to use "wordset-" prefix since this file is glossed

    with the line that starts the definition of .WORD highlighted by
    colour.

    - 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: https://forth-standard.org/
    EuroForth 2022: https://euro.theforth.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Heinrich Hohl@21:1/5 to minf...@arcor.de on Tue Mar 14 01:53:22 2023
    On Tuesday, March 14, 2023 at 8:22:19 AM UTC+1, minf...@arcor.de wrote:
    Try
    LOCATE <wordname> to display the source
    or
    SEE <wordname> to display the compiled code.

    In SwiftForth you can also use

    EDIT <wordname>

    This command will open the source file that contains the related word.
    In case of core words you need the source files for SwiftForth. I assume
    that these are only included in the paid version.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From none) (albert@21:1/5 to vkichline@gmail.com on Tue Mar 14 13:40:53 2023
    In article <de275b70-14bd-4f10-88e0-20ded3222bf4n@googlegroups.com>,
    Van Kichline <vkichline@gmail.com> wrote:
    I am learning Forth and switch contexts often to look up word definitions to check the parameters.
    I am considering writing a word "se" for Stack-Effects. Typing "se word" would respond with a stack effect comment from a
    list which I assume I'd curate.
    A good design would allow me to specify the dialect in use as well as custom lists, but I plan to start with a usable
    subset consisting of just gForth words.
    Before I begin, I'd like to ask if this has this already been done (better than I am likely to do it.) I would still do
    my own, but seeing a good design would be instructive.

    I added the stack effect for each individual word in the header
    for optimisition purposes.
    See forthlectureE.html on my site below. Decompilation or WORDS
    show color effects in the source (a kind of syntax highlighting).

    Groetjes Albert
    --
    Don't praise the day before the evening. One swallow doesn't make spring.
    You must not say "hey" before you have crossed the bridge. Don't sell the
    hide of the bear until you shot it. Better one bird in the hand than ten in
    the air. First gain is a cat spinning. - the Wise from Antrim -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From S Jack@21:1/5 to Van Kichline on Tue Mar 14 07:04:54 2023
    On Monday, March 13, 2023 at 6:44:43 PM UTC-5, Van Kichline wrote:
    I am learning Forth and switch contexts often to look up word definitions to check the parameters.
    I am considering writing a word "se" for Stack-Effects. Typing "se word" would respond with a stack effect comment from a list which I assume I'd curate.
    A good design would allow me to specify the dialect in use as well as custom lists, but I plan to start with a usable subset consisting of just gForth words.
    Before I begin, I'd like to ask if this has this already been done (better than I am likely to do it.) I would still do my own, but seeing a good design would be instructive.

    Go for it. Will be good experience.
    --
    me

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From S Jack@21:1/5 to S Jack on Tue Mar 14 07:45:32 2023
    On Tuesday, March 14, 2023 at 9:04:57 AM UTC-5, S Jack wrote:
    On Monday, March 13, 2023 at 6:44:43 PM UTC-5, Van Kichline wrote:
    I am learning Forth and switch contexts often to look up word definitions to check the parameters.

    I'm hosted by linux and use vim which as other major editors have the
    ability to hide lines of text except for the first line. Place cursor
    on displayed line and all the hidden lines are displayed. A fantastic
    feature. I have many Bash scripts that operate on what I call record
    files, ones marked up (very simply) with text line records. The
    text record titles can be listed, searched and their content extracted.
    Most all my Forth source is maintained in record files and can be
    directly loaded into the Forth which understands the markup. A simple
    system call can access the Bash scripts for the existing record file operations. In the Forth source file the record titles are the names
    of Forth words and their stack effects. I have a Bash interface script
    that can locate and extract individual Forth words. Because I use
    record files for non-Forth work I have the Bash scripts and just
    incorporated them into my Forth rather than re-invent the wheel in
    Forth. Not any means suggesting you do the same. Write your own Forth application; will get you familiar working in Forth and at same time
    become familiar with the words.
    --
    me

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Van Kichline@21:1/5 to Anton Ertl on Tue Mar 14 17:05:10 2023
    On Tuesday, March 14, 2023 at 1:45:17 AM UTC-7, Anton Ertl wrote:
    Van Kichline <vkic...@gmail.com> writes:
    I am considering writing a word "se" for Stack-Effects. Typing "se word" would respond with a stack effect comment from a list which I assume I'd curate.
    A good design would allow me to specify the dialect in use as well as custom lists, but I plan to start with a usable subset consisting of just gForth words.
    In the development version of Gforth you can type "help word" and you
    get the documentation for the word if it is documented, or the source
    code of the word otherwise. Both include the stack effect.

    E.g., "help word" outputs:

    |doc/gforth.txt:8641
    |'word' ( char "<chars>ccc<char>-- c-addr ) core "word"
    | Skip leading delimiters. Parse ccc, delimited by char, in the parse
    |area. c-addr is the address of a transient region containing the parsed |string in counted-string format. If the parse area was empty or
    |contained no characters other than delimiters, the resulting string has |zero length. A program may replace characters within the counted
    |string. OBSOLESCENT: the counted string has a trailing space that is
    |not included in its length.

    while "help .word" outputs:

    |No documentation for .word, LOCATEing source
    |kernel/tools.fs:111
    |
    |Defer word-colorize ' noop is word-colorize
    |
    |: .word ( n nt -- n' )
    | dup >r name>string tuck 2>r
    | 1+ tuck + dup cols >= IF cr drop ELSE nip THEN
    | 2r> r> word-colorize drop type space default-color ;
    |
    |: wordlist-words ( wid -- ) \ gforth
    | \G Display the contents of the wordlist wid.
    | 0 swap cr ['] .word map-wordlist drop ;
    |
    |: words ( -- ) \ tools
    | \G ** this will not get annotated. See other defn in search.fs .. **
    | \G It does not work to use "wordset-" prefix since this file is glossed

    with the line that starts the definition of .WORD highlighted by
    colour.

    - 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: https://forth-standard.org/
    EuroForth 2022: https://euro.theforth.net
    I had failed to notice that there was a development version of gForth (of failed to realize why I would want it.)
    Of all the fine solutions offered here, this seems the best for me. I am easily distracted by browsers and like to keep my eye on the command line.
    Thanks!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Van Kichline@21:1/5 to S Jack on Tue Mar 14 17:13:53 2023
    On Tuesday, March 14, 2023 at 7:04:57 AM UTC-7, S Jack wrote:
    On Monday, March 13, 2023 at 6:44:43 PM UTC-5, Van Kichline wrote:
    I am learning Forth and switch contexts often to look up word definitions to check the parameters.
    I am considering writing a word "se" for Stack-Effects. Typing "se word" would respond with a stack effect comment from a list which I assume I'd curate.
    A good design would allow me to specify the dialect in use as well as custom lists, but I plan to start with a usable subset consisting of just gForth words.
    Before I begin, I'd like to ask if this has this already been done (better than I am likely to do it.) I would still do my own, but seeing a good design would be instructive.
    Go for it. Will be good experience.
    --
    me
    I still thinks so myself. Maybe it's only the right tool for me. But that's what Forth is for (I think.)
    My current plan is: create a new word list. Redefine the words of interest there, each with a body which simply prints its stack effect.
    A word like 'se' would switch to that wordlist only, execute the word, then restore the word list and search order.
    I have no experience with this part of Forth, I've just read about vocabularies in older Forth books. It seems like the dictionary is exactly the right tool for looking up Forth words, though.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)