6.1.2165 S" s-quote CORE

Interpretation:

Interpretation semantics for this word are undefined.

Compilation:

( "ccc<quote>" -- )

Parse ccc delimited by " (double-quote). Append the run-time semantics given below to the current definition.

Run-time:

( -- c-addr u )

Return c-addr and u describing a string consisting of the characters ccc. A program shall not alter the returned string.

See:

Rationale:

Typical use: : X ... S" ccc" ... ;

Testing:

T{ : GC4 S" XY" ; ->   }T
T{ GC4 SWAP DROP  -> 2 }T
T{ GC4 DROP DUP C@ SWAP CHAR+ C@ -> 58 59 }T

: GC5 S" A String"2DROP ; \ There is no space between the " and 2DROP
T{ GC5 -> }T

ContributeContributions

flaagelavatar of flaagel [219] Forth Programmer's HandbookExample2022-02-12 16:13:14

defines an interpretation semantics for S" as:

'If interpreting, return the address and length of the following string, terminated by ", which is in a temporary buffer.'

This particular semantics seems to have been withdrawn from the Forth2012 specification, Any particular rationale for that?

flaagelavatar of flaagel

Also, I think the outcome of the test should not depend on the current BASE.

T{ GC4 DROP DUP C@ SWAP CHAR+ C@ -> $58 $59 }T

works fine over here...

ruvavatar of ruv

This particular semantics seems to have been withdrawn from the Forth2012 specification

The Forth 2012 standard (as well as Forth 94) specifies two versions of the the word S": in the CORE word set (the minimal conformance level), and in the optional File-Access word set. In the former version interpretation semantics are undefined, but in the latter version they are defined.

So, take a look on the glossary entry for FILE S" — Forth Programmer's Handbook describes this version.

ruvavatar of ruv

the outcome of the test should not depend on the current BASE.

More precisely, it should not rely on not decimal BASE

It's a known problem if the test suite, and of course it should be fixed.

GeraldWodniavatar of GeraldWodni

As discussed in the electronic interim meeting 2022i1: We should revisit the testcase once the next snapshot is published and the testcases are re-imported into the website.

Closed

JohanKotlinskiavatar of JohanKotlinski

What about multi-line strings? From the standard text, one could believe that the following would work:

s" foo
bar"

However, it seems like it is not working in all Forths. Is it permissible, and why?

JohanKotlinskiavatar of JohanKotlinski

XXX Regarding multi-line S", I found comments in https://forth-standard.org/standard/core/PARSE which explain the situation as well as can be hoped for.

Reply New Version