• Re: Better WORDS, please!

    From mhx@21:1/5 to LIT on Sun Dec 24 09:38:22 2023
    LIT wrote:

    That too. Every new forth I tried I would dump its words to keep
    as a sorted quick reference.

    The limited usefulness of WORDS has always irritated me, too.
    In the old days, the teletype or VDU's baudrate slowed it down to
    readable speed.

    iForth uses a console window to interact with the user, and this console
    can be configured to have any size scrollback buffer. Mark, search, and
    moused copy-and-paste (to the line editor) all work on modern consoles.

    Then there is WORDS-DELAY :
    FORTH> help words-delay
    WORDS-DELAY IFORTH
    ( -- a-addr )
    Contains the number of milliseconds to wait per line of output in
    WORDS WORDS: and WORDS?
    See also: WORDS WORDS: and WORDS?

    'WORDS: abc' shows only those words containing substring abc, WORDS?
    allows a grep-like pattern like *ape or a?pe.

    Old CLF discussions resulted in doWORDS

    FORTH> help doWORDS
    doWORDS IFORTH
    ( xt -- count-of-matched-entries )
    The wordlist traversing factor of WORDS WORDS: and WORDS?
    Supply the xt of a word that can filter ( addr -- bool ) where
    addr is the address of a counted string (name of the next word
    in the list). For example, to realize a clone of WORDS that only
    prints short words you can do:
    : SWORDS-XT ( addr -- bool ) C@ 3 < ; ' SWORDS-XT doWORDS DROP .

    Further manipulation is possible with HELP <word>, LOCATE <word>, e.g.
    FORTH> locate +
    File: d:dfwforth/x64/inc/kernel.inc
    1834: T: NEGATE NEGATE T; ANS <w> --- <-w>
    1835: T: BSWAP BSWAP T; <w1> --- <w2>
    1836: T: - - T; ANS <u> <u> --- <u>
    1837>> T: + + T; ANS <u> <u> --- <u>
    1838: T: CELL+ CELL+ T; ANS <addr> --- <addr+>
    1839: T: CELL- CELL- T; <addr-> --- <addr->
    1840: T: CELLS CELLS T; ANS <n> --- <n*> ok

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From none) (albert@21:1/5 to LIT on Sun Dec 24 11:04:39 2023
    In article <980a047687a8dfd0e2df160ec6e93d93@news.novabbs.com>,
    LIT <zbigniew2011@gmail.com> wrote:
    I actually don't understand, why no Forth creator inserts
    into his design WORDS, that allow to examine what's actually
    „inside”. Perhaps the worst example is FPC Forth — 1500 words
    making just „zooooooooooom!” throught the screen, like a thunder,
    when one types WORDS.

    No it isn't. It is supposed to run on a PC that is so slow that
    you have plenty of time to hit the space button before the first
    screen ;-)


    It doesn't seem to be that difficult to create „paged” WORDS; here's
    my simple take (it's fig-Forth):

    : WORDS ( -- )
    0 OUT C! 22 OUT 1+ C! CR
    CONTEXT @ @
    BEGIN
    DUP ID. SPACE PFA LFA @ DUP 0=
    OUT C@ C/L >
    IF CR 0 OUT C! OUT 1+ DUP C@ 1- SWAP C! THEN
    OUT 1+ C@ 0= DUP
    IF DROP 22 OUT 1+ C! ." >>> ENTER to continue -- any other key to end <<<"
    CR KEY 13 = 0= 0 OUT C! THEN ( OUT-lo "reset" because of the message )
    OR
    UNTIL DROP ;

    (yes, a few „magic numbers”, but no big deal; 22 is the lines' count)


    Nevertheless valuable. I just tried out fpc and was pleasantly surprised
    of its interactive quality and its build in documentation.

    WORDS should display the words in recent last order such as in ciforth.
    You are interested in the words you defined yourself.

    It is trivial, leave a sentinel 0 on the stack
    : WORDS
    0 'NOOP CONTEXT @ FOR-WORDS \ Leave the addresses of all the words
    BEGIN DUP WHILE ID. REPEAT DROP \ Now print the id giving its address.
    ;

    I can't believe that nobody has copied this.
    Note that it is less code than your solution, and in a system you
    can subtract the original code that WORDS occupied for a total
    expense of half a dozen WOC and no extra headers.

    --
    Z.

    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 none) (albert@21:1/5 to All on Sun Dec 24 12:52:23 2023
    In article <2232c750331a17c5160fa56c6bc99f2a@news.novabbs.com>,
    <SNIP>
    It's still not paged, unfortunately. What if I want to browse
    the „initial” words? In Linux' environment I can use scrollback
    buffer (but not always! Kudos to Mark Manning for implementing
    his WORDS as „paged”) fortunately — but in MS-DOS (or similar)
    there's a problem. The simple solution is: just to split WORDS'
    output into separate pages. In such situation the „old” usual
    list order is even better: you'll find your words immediately,
    without a need to get to the last screen

    Of corse you have a separate window with the Forth words ordered
    by initial letter, as well as ordered by wordset in html where
    you can click on ALSO's if something is not clear.

    --
    Z.

    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 David N. Williams@21:1/5 to JKN on Sun Dec 24 09:08:09 2023
    On 12/23/23 2:51 PM, JKN wrote:
    [...]

    possibly because a better way to do it would be to decouple the source
    of the character stream (ie WORDS), and the paging mechanism, so that
    the latter could be used for any input stream. In a similar way to how
    in Unix/Linux you can 'pipe' a stream to 'more' to get paged output.

    (I would hope that at least some Forths work like this, but I confess
    I have no idea if this is true)

    \ Portable Forth Environment 0.33.73w (Aug 21 2021 09:34:46)
    Copyright (C) Dirk Uwe Zoller 1993 - 1995.
    Copyright (C) Tektronix, Inc. 1998 - 2003.
    Copyright (C) Guido U. Draheim 2005 - 2008.
    ANS/ffa ITC Forth - Please enter LICENSE and WARRANTY.
    Running on x86_64 darwin20.6.0 - to quit say BYE. ok
    words
    C K-SHIFT-MASK p EKEY>FKEY C K-SHIFT-F10
    C K-SHIFT-F9 C K-SHIFT-F8 C K-SHIFT-F7
    C K-SHIFT-F6 C K-SHIFT-F5 C K-SHIFT-F4
    C K-SHIFT-F3 C K-SHIFT-F2 C K-SHIFT-F1
    ...
    p EXITCODE p ARGV p ARGC
    p APPLICATION p EDIT-BLOCKFILE p HELP
    p STANDARD-I/O p (TYPE) p (KEY)
    p (EXPECT) p (EMIT) p *TYPE*
    p *KEY* p *EXPECT* p *EMIT*
    more?

    Pressing return gets you another line, and the space bar gets you
    another page. I don't remember the significance of the C and p
    prefixes, which is also not explained by

    help words
    /usr/local/include/pfe/tools-ext.h:
    /** WORDS ( -- )
    * uses CONTEXT and lists the words defined in that vocabulary.
    * usually the vocabulary to list is named directly in before.
    example:
    FORTH WORDS or LOADED WORDS
    */
    ok

    At least the second line hints at which source file to look in to find
    that out, namely, tools-ext.c.

    -- David W.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to David N. Williams on Sun Dec 24 15:23:36 2023
    "David N. Williams" <williams@umich.edu> writes:
    \ Portable Forth Environment 0.33.73w (Aug 21 2021 09:34:46)
    Copyright (C) Dirk Uwe Zoller 1993 - 1995.
    Copyright (C) Tektronix, Inc. 1998 - 2003.
    Copyright (C) Guido U. Draheim 2005 - 2008.
    ANS/ffa ITC Forth - Please enter LICENSE and WARRANTY.
    Running on x86_64 darwin20.6.0 - to quit say BYE. ok
    words
    C K-SHIFT-MASK p EKEY>FKEY C K-SHIFT-F10
    C K-SHIFT-F9 C K-SHIFT-F8 C K-SHIFT-F7
    C K-SHIFT-F6 C K-SHIFT-F5 C K-SHIFT-F4
    C K-SHIFT-F3 C K-SHIFT-F2 C K-SHIFT-F1
    ...
    p EXITCODE p ARGV p ARGC
    p APPLICATION p EDIT-BLOCKFILE p HELP
    p STANDARD-I/O p (TYPE) p (KEY)
    p (EXPECT) p (EMIT) p *TYPE*
    p *KEY* p *EXPECT* p *EMIT*
    ...
    I don't remember the significance of the C and p
    prefixes

    Looking at these words, my guess is:

    C: constant
    p: primitive

    - 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 2023: https://euro.theforth.net/2023

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to LIT on Sun Dec 24 15:25:46 2023
    zbigniew2011@gmail.com (LIT) writes:
    It doesn't seem to be that difficult to create "paged" WORDS

    In Gforth, if you want the output of words to be paged, you

    require more.fs

    I find it cool that this can be added in a Forth system without having
    to change every word that outputs multiple lines.

    One other "better WORDS" is Martin Bitter's MWORDS. This lists all
    words that contain a certain string. You can find it on <http://theforth.net/package/mwords>.

    - 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 2023: https://euro.theforth.net/2023

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to dxf on Sun Dec 24 16:46:46 2023
    dxf <dxforth@gmail.com> writes:
    On 25/12/2023 2:25 am, Anton Ertl wrote:
    zbigniew2011@gmail.com (LIT) writes:
    It doesn't seem to be that difficult to create "paged" WORDS

    In Gforth, if you want the output of words to be paged, you

    require more.fs

    I find it cool that this can be added in a Forth system without having
    to change every word that outputs multiple lines.
    ...

    That would get very annoying, very quickly - no? Paging poses a similar >problem in that the user is required to enter a key to progress.

    That's why more.fs is not loaded by default. Some people work in an environment where it is useful, most have scroll-back support and
    don't need it.

    - 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 2023: https://euro.theforth.net/2023

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David N. Williams@21:1/5 to Anton Ertl on Sun Dec 24 17:04:06 2023
    On 12/24/23 10:23 AM, Anton Ertl wrote:
    "David N. Williams" <williams@umich.edu> writes:
    \ Portable Forth Environment 0.33.73w (Aug 21 2021 09:34:46)
    Copyright (C) Dirk Uwe Zoller 1993 - 1995.
    Copyright (C) Tektronix, Inc. 1998 - 2003.
    Copyright (C) Guido U. Draheim 2005 - 2008.
    ANS/ffa ITC Forth - Please enter LICENSE and WARRANTY.
    Running on x86_64 darwin20.6.0 - to quit say BYE. ok
    words
    C K-SHIFT-MASK p EKEY>FKEY C K-SHIFT-F10
    C K-SHIFT-F9 C K-SHIFT-F8 C K-SHIFT-F7
    C K-SHIFT-F6 C K-SHIFT-F5 C K-SHIFT-F4
    C K-SHIFT-F3 C K-SHIFT-F2 C K-SHIFT-F1
    ...
    p EXITCODE p ARGV p ARGC
    p APPLICATION p EDIT-BLOCKFILE p HELP
    p STANDARD-I/O p (TYPE) p (KEY)
    p (EXPECT) p (EMIT) p *TYPE*
    p *KEY* p *EXPECT* p *EMIT*
    ...
    I don't remember the significance of the C and p
    prefixes

    Looking at these words, my guess is:

    C: constant
    p: primitive

    That sounds right. Thanks!

    -- David W.

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