-( Compile-mode word which compiles everything until the next
- double quote as a litstring. )
-: S" IMMEDIATE ( -- addr len )
- ['] LITSTRING , ( compile LITSTRING )
- HERE ( save the address of the length word on the stack )
- 0 , ( dummy length - we don't know what it is yet )
+: COMPILING? STATE @ 0<> ;
+
+( In compile mode, word compiles everything until the next
+ double quote as a litstring. Otherwise, dynamically allocates
+ memory and stores string there, returning address and length. )
+: S" IMMEDIATE ( -- addr len )
+ COMPILING? IF
+ ['] LITSTRING , ( compile LITSTRING )
+ HERE ( save the address of the length word on the stack )
+ 0 , ( dummy length - we don't know what it is yet )
+ ELSE
+ HERE ( save the starting address on the stack )
+ THEN