• Re: portable or =?UTF-8?B?bm90PyBWb2xhdGlsZSBzdHJpbmdz?=

    From mhx@21:1/5 to albert@spenarnc.xs4all.nl on Tue Aug 13 18:44:49 2024
    On Mon, 12 Aug 2024 9:01:48 +0000, albert@spenarnc.xs4all.nl wrote:


    Okay let's say it out loud. Classic Forth is not fit for handling
    strings.

    I don't agree. Classic Forth is perfectly fit for handling strings.
    It just needs some user-defined words added. The longer such words
    are not standardized, the better the final result will probably be.

    A denotation that generates a constant string "blablabla" that has
    a status as a number is long overdue.

    Which illustrates my point. Having a built-in string type denoted
    by quotes might be a good thing. It is hard to find a argument
    against that when numbers are already a comparable exception that
    nobody has found a way to get rid of. And maybe we can then even
    tick strings and numbers like everything else?

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to mhx on Wed Aug 14 07:03:52 2024
    mhx@iae.nl (mhx) writes:
    Having a built-in string type denoted
    by quotes might be a good thing. It is hard to find a argument
    against that when numbers are already a comparable exception that
    nobody has found a way to get rid of.

    Mitch Bradley introduced parsing words for numbers, which would allow
    to get rid of the number recognizers.

    But yes, the mainstream is in the opposite direction: Introduce
    recognizers not just for numbers, but also for strings, and a
    mechanism for user-defined recognizers.

    And maybe we can then even
    tick strings and numbers like everything else?

    I explored this idea in a EuroForth 2016 paper, in particular in
    Section 4.1.

    @InProceedings{ertl-recognizers16,
    author = {M. Anton Ertl},
    title = {Recognizers: Arguments and Design Decisions},
    crossref = {euroforth16},
    pages = {58--63},
    url = {https://www.complang.tuwien.ac.at/papers/ertl-recognizers16.pdf},
    video = {https://wiki.forth-ev.de/lib/exe/fetch.php/events:recognizers.mp4},
    OPTnote = {not refereed},
    abstract = {The Forth text interpreter processes words and
    numbers. Currently the set of words can be extended
    by programmers, but not the recognized numbers.
    User-defined recognizers allow to extend the
    number-recognizer part, too. This paper shows the
    benefits of recognizers and discusses
    counterarguments. It also discusses several design
    decisions: Whether to define temporary words, or a
    set of interpretation, compilation, and postponing
    actions; and whether to hook the recognizers inside
    \code{find} or in the text interpreter.}
    }

    @Proceedings{euroforth16,
    title = {32nd EuroForth Conference},
    booktitle = {32nd EuroForth Conference},
    year = {2016},
    key = {EuroForth'16},
    url = {https://www.complang.tuwien.ac.at/anton/euroforth/ef16/papers/proceedings.pdf}
    }

    The discussion has moved on since then, and getting the xt of a
    recognized thing is not something that anyone (including me) found
    worth the cost, so AFAIK nobody has implemented the temporary-word
    approach.

    However, if we adopt Gerry Jackson's attitude and make every transient
    region permanent, creating a new permanent word (in a separate
    section) for every parsed number, string, etc. is fine, and ticking
    that word is fine, too. For most programs, the space taken by the
    recognized words is proportional to the size of the source code, which
    is acceptable on desktops with GBs of RAM. However, programs that use
    EVALUATE a lot will need more recognized-word storage. A contrived
    example is:

    : foo 1000000000 0 ?do s" 123" evaluate drop loop ; foo

    You might imagine optimizing this by using only one definition for all
    these occurences of "123", so here's another example where that
    optimization would not work:

    : bar 1000000000 0 ?do i 0 <# #s #> evaluate drop loop ; bar

    Of course, if you make all transient regions permanent, already the <#
    #s #> consumes a lot of memory in BAR, and the recognized words just
    increase this by a constant factor.

    While I have some sympathies for the idea of permanent "transient"
    data (e.g., in Gforth S"'s intepretation semantics produce a string
    that lives until the end of the session, I don't think that this would
    find consensus in the standards committee.

    And if you really want an execution token for a string or number,
    writing

    [: s" foo" ;] [: 123 ;]

    inside a colon definition (or the same with :NONAME ... ; outside a
    colon definition) seems easy enough.

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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to dxf on Wed Aug 14 07:41:07 2024
    On Wed, 14 Aug 2024 2:09:12 +0000, dxf wrote:

    On 14/08/2024 4:44 am, mhx wrote:
    [..]
    Which illustrates my point. Having a built-in string type denoted
    by quotes might be a good thing.
    [..]
    'might be a good thing' - these would have to be the most used words
    in Forth :)

    Here I genuinely meant that I don't know if it is really a good
    thing, but *my* mind is open to it.

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to Anton Ertl on Wed Aug 14 12:25:16 2024
    In article <2024Aug14.090352@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    mhx@iae.nl (mhx) writes:
    Having a built-in string type denoted
    by quotes might be a good thing. It is hard to find a argument
    against that when numbers are already a comparable exception that
    nobody has found a way to get rid of.

    Mitch Bradley introduced parsing words for numbers, which would allow
    to get rid of the number recognizers.

    But yes, the mainstream is in the opposite direction: Introduce
    recognizers not just for numbers, but also for strings, and a
    mechanism for user-defined recognizers.

    You need a magnifying glass to see the difference:
    Bradly: 0x DEADBEEF
    We: 0xDEAFBEAF

    I think recognizing 0xDEADBEAF as a number (pun intended),
    one can proceed without adjusting the notion of what a number is.

    Having a mechanism that recognizing the Intel DEADBEEFH is a bridge too far.

    <SNIP>
    - anton
    --
    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 purring. - the Wise from Antrim -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to albert@spenarnc.xs4all.nl on Wed Aug 14 14:06:25 2024
    On Wed, 14 Aug 2024 10:38:55 +0000, albert@spenarnc.xs4all.nl wrote:

    [..]

    Example
    CREATE $VAR1 100 ALLOT
    "AAP" \ is permanent. (somehow )
    2DUP $VAR1 $! \ You take responsibilty that `$VAR is large enough
    \ The constant string is still on the stack and can be reused.

    Oh, now you point to an unwanted, or complicating, effect.
    The phrase ' "aap" must create the string before its descriptor
    can be returned. Unless, of course, "aap" exists already. A ticked
    number has the same problem.

    Just make that exception?

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to mhx on Wed Aug 14 20:49:45 2024
    In article <9f0673c854a961df63960f6a435ae0b9@www.novabbs.com>,
    mhx <mhx@iae.nl> wrote:
    On Wed, 14 Aug 2024 10:38:55 +0000, albert@spenarnc.xs4all.nl wrote:

    [..]

    Example
    CREATE $VAR1 100 ALLOT
    "AAP" \ is permanent. (somehow )
    2DUP $VAR1 $! \ You take responsibilty that `$VAR is large enough
    \ The constant string is still on the stack and can be reused.

    Oh, now you point to an unwanted, or complicating, effect.
    The phrase ' "aap" must create the string before its descriptor
    can be returned. Unless, of course, "aap" exists already. A ticked
    number has the same problem.

    Just make that exception?

    What?

    Ticking a constant or constant string makes no sense.
    At most it is the same constant again.

    AMDX86 ciforth 5.5.1
    "AAP"
    OK
    2DUP TYPE
    AAP OK
    2DUP TYPE
    AAP OK
    .S

    S[ 4250664 3 ] OK
    ' "AAP"
    ' "AAP" ? ciforth ERROR # 11 : WORD IS NOT FOUND
    ' 12
    ' 12 ? ciforth ERROR # 11 : WORD IS NOT FOUND


    -marcel

    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 purring. - the Wise from Antrim -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to albert@spenarnc.xs4all.nl on Wed Aug 14 19:46:48 2024
    On Wed, 14 Aug 2024 18:49:45 +0000, albert@spenarnc.xs4all.nl wrote:
    Ticking a constant or constant string makes no sense.

    Try

    ' +INF

    It takes forever.

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