,---------------. | Contributions | `---------------´ ,------------------------------------------ | 2019-10-03 14:30:28 ruv wrote: | referenceImplementation - Case-sensitivity independent implementation | see: https://forth-standard.org/standard/tools/BracketELSE#contribution-121 `------------------------------------------ If a Forth system can optionally turn on case-insensitivity, it does not affect by default `[IF] ... [ELSE] ...[THEN]` control structure in the provided reference implementation. The following implementation variant obeys the system's case sensitivity mode. ``` WORDLIST DUP CONSTANT BRACKET-FLOW-WL GET-CURRENT SWAP SET-CURRENT : [IF] ( level1 -- level2 ) 1+ ; : [ELSE] ( level1 -- level2 ) DUP 1 = IF 1- THEN ; : [THEN] ( level1 -- level2 ) 1- ; SET-CURRENT : [ELSE] ( -- ) 1 BEGIN BEGIN PARSE-NAME DUP WHILE BRACKET-FLOW-WL SEARCH-WORDLIST IF EXECUTE DUP 0= IF DROP EXIT THEN THEN REPEAT 2DROP REFILL 0= UNTIL DROP ; IMMEDIATE : [THEN] ( -- ) ; IMMEDIATE : [IF] ( flag -- ) 0= IF POSTPONE [ELSE] THEN ; IMMEDIATE ``` ,---------. | Replies | `---------´ ,------------------------------------------ | 2019-10-03 11:33:36 ruv replies: | referenceImplementation - Reference implementation of SYNONYM | see: https://forth-standard.org/standard/tools/SYNONYM#reply-337 `------------------------------------------ The standard says nothing about "STATE-smart words" in the normative parts. How can you infer from the standard that the existing reference implementation is broken? It seems for me that this implementation does not violate the specification for `SYNONYM` word. ,------------------------------------------ | 2019-10-03 12:09:02 ruv replies: | testcase - Test cases for SYNONYM | see: https://forth-standard.org/standard/tools/SYNONYM#reply-338 `------------------------------------------ An incorrect test cannot show that an implementation is incorrect. The following test is incorrect: ``` t{ 1 2 ' my-+ ]execute[ -> 3 }t ``` Tick returns an identifier for execution semantics, but according to the specification, execution semantics is not defined for the words that created via `SYNONYM`. Therefore you try to test undefined behavior. And even the controversial clause "When interpreting, `' xyz EXECUTE` is equivalent to `xyz`"[1] does not support this test since `]execute[` is not equivalent to `EXECUTE`. Also, the result of the following test cannot be forecast from the reference implementation: ``` t{ : comp-my+ postpone my-+ ; -> }t t{ : ya-+ [ comp-my+ ] ; -> }t t{ 1 2 ya-+ -> 3 }t ``` Since depending on implementation of `POSTPONE` it can be success or failed. Therefore, this test cannot refute the reference implementation, since in some Forth system (with this reference implementation) this test can be success. ----- [1] From [6.1.0070](https://forth-standard.org/standard/core/Tick). This clause actually represents merely the default interpretation semantics, see [3.4.3.2](https://forth-standard.org/standard/usage#subsubsection.3.4.3.2).