6.2.2535 \ backslash CORE EXT

Compilation:

Perform the execution semantics given below.

Execution:

( "ccc<eol>" -- )

Parse and discard the remainder of the parse area. \ is an immediate word.

See:

Rationale:

Typical use:
5 CONSTANT THAT \ This is a comment about THAT

ContributeContributions

JimPetersonavatar of JimPeterson [289] Maybe `REFILL`?Suggested reference implementation2023-02-23 16:26:01

Is this, effectively: : \ REFILL DROP ; IMMEDIATE ?

The description says "... parse and discard...", but wouldn't simply "... discard..." suffice? Also, REFILL strongly implies that it operates one line at a time. Maybe that is specified elsewhere in the spec?

ruvavatar of ruv

Is this, effectively:

: \ REFILL DROP ; IMMEDIATE

It isn't acceptable, since REFILL may change the input buffer, but "\" must not change the input buffer.

See 3.3.3.5 Input buffers: "The address and length returned by SOURCE, the string returned by PARSE, and directly computed input-buffer addresses are valid only until the text interpreter does I/O to refill the input buffer or the input source is changed".

wouldn't simply "... discard..." suffice?

"To parse" is a formal term, which also refers "3.4.1 Parsing" that describes the behavior in details (i.e, how >IN is changed). "Discard" means that the parsed string is not used. Without "parse" the specified behavior would be less clear.

REFILL strongly implies that it operates one line at a time.

In the general case, it depends on the input source kind. If you want to be independent on that kind, you cannot assume that REFILL operates on text lines. See my post Portable line-oriented parsing on this regard.

Reply New Version

TammoFreeseavatar of TammoFreese [351] Reuse a test for SOURCE as a starting point for a reference implementationSuggested reference implementation2024-07-25 16:53:47

One of the tests of SOURCE (the word GS4) discards the remainder of the parse area using SOURCE >IN ! DROP. Making it immediate may be enough to make it a reference implementation for the backslash word:

: \ SOURCE >IN ! DROP ; IMMEDIATE
Reply New Version