• What use is SLITERAL?

    From albert@[email protected] to comp.lang.forth on Mon Nov 3 13:40:02 2025
    From Newsgroup: comp.lang.forth

    What is the use case for SLITERAL.

    : test [ "AAP" ] SLITERAL ;

    Assuming "AAP" is made permanent you can as wel say

    : test [ "AAP" ] DLITERAL ;

    or
    : test "AAP" ;

    or
    "AAP" 2CONSTANT q
    : test q TYPE ;
    or
    DATA q 3 , &A C, &A C, &P C,
    : test q $@ TYPE ;

    I can't think if a case where SLITERAL is *not* preceeded by
    [ ] because : is allowed to leave colon-sys .

    Groetjes Albert
    --
    The Chinese government is satisfied with its military superiority over USA.
    The next 5 year plan has as primary goal to advance life expectancy
    over 80 years, like Western Europe.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From anton@[email protected] (Anton Ertl) to comp.lang.forth on Mon Nov 3 17:47:56 2025
    From Newsgroup: comp.lang.forth

    [email protected] writes:
    What is the use case for SLITERAL.

    : test [ "AAP" ] SLITERAL ;
    ...
    : test "AAP" ;

    I.e. SLITERAL is not useful for this purpose.

    I can't think if a case where SLITERAL is *not* preceeded by
    [ ] because : is allowed to leave colon-sys .

    The Gforth source code contains the following occurences:

    kernel/quotes.fs:74:28: :noname '"' parse postpone SLiteral ; kernel/quotes.fs:88:28: :noname '"' parse postpone SLiteral postpone type ; utf-8.fs:330:55: r> I delta-I [ #cr pad c! #lf pad 1+ c! pad 2 ] SLiteral string-prefix? -
    utf-8.fs:348:55: r> I delta-I [ #cr pad c! #lf pad 1+ c! pad 2 ] SLiteral string-prefix? -
    quotes.fs:144:63: :noname ['] singleline-string \"-parse save-mem 2dup postpone sliteral drop free throw ;
    ekey.fs:302:27: [ pad 3 $80 fill pad 3 ] SLiteral
    rec-string.fs:37:14: postpone sliteral ;
    libcc.fs:944:4: ] sliteral
    libcc.fs:955:4: ] sliteral
    libcc.fs:965:81: libtool-cc $type libtool-flags $type s" -module -rpath " $type tmp$ $@ ] sliteral type
    libcc.fs:1170:45: 2drop [ s" libccdir" getenv ':' 0 substc ] SLiteral locate1.fs:658:28: :noname '`' parse postpone SLiteral postpone sh-get ;

    5 uses without preceding ], all of those preceded by POSTPONE.

    Those with preceding ] tend to have their strings stored in volatile
    storage.

    The usage at quotes.fs:144:63 makes me wonder; first the string is
    SAVE-MEMed (stored on the heap), then SLITERALed, and then the heap
    storage is freed. Maybe the expectation was that \"-PARSE stores the
    string in a place that SLITERAL may overwrite. Maybe that's no longer
    the case.

    - 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 2025 CFP: http://www.euroforth.org/ef25/cfp.html
    EuroForth 2025 registration: https://euro.theforth.net/
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From dxf@[email protected] to comp.lang.forth on Tue Nov 4 13:26:02 2025
    From Newsgroup: comp.lang.forth

    On 3/11/2025 11:40 pm, [email protected] wrote:
    What is the use case for SLITERAL.

    : test [ "AAP" ] SLITERAL ;

    Assuming "AAP" is made permanent you can as wel say

    : test [ "AAP" ] DLITERAL ;

    or
    : test "AAP" ;

    or
    "AAP" 2CONSTANT q
    : test q TYPE ;
    or
    DATA q 3 , &A C, &A C, &P C,
    : test q $@ TYPE ;

    I can't think if a case where SLITERAL is *not* preceeded by
    [ ] because : is allowed to leave colon-sys .

    As with LITERAL, SLITERAL is designed to compile a computed object?

    : module ( u siz "name" -- u2 )
    over + tuck 1- 2constant
    does> 2@ [ loadfile -path ] sliteral loaded ;

    --- Synchronet 3.21a-Linux NewsLink 1.2