,---------------. | Contributions | `---------------´ ,------------------------------------------ | 2018-01-08 17:54:46 NieDzejkob wrote: | referenceImplementation - Suggested reference implementation | see: https://forth-standard.org/standard/core/CComma#contribution-49 `------------------------------------------ `: C, ( char -- ) HERE @ TUCK ! CHAR+ HERE ! ;` ,---------. | Replies | `---------´ ,------------------------------------------ | 2018-01-08 15:41:47 alextangent replies: | referenceImplementation - Suggested reference implementation | see: https://forth-standard.org/standard/core/FILL#reply-95 `------------------------------------------ -ROT is not in the standard. A reference implementation should (must?) use standard words. ,------------------------------------------ | 2018-01-08 15:43:39 alextangent replies: | referenceImplementation - Suggested reference implementation | see: https://forth-standard.org/standard/core/TwoSWAP#reply-96 `------------------------------------------ -ROT is not in the standard. A reference implementation should (must?) use standard words. ,------------------------------------------ | 2018-01-08 15:51:30 NieDzejkob replies: | referenceImplementation - Suggested reference implementation | see: https://forth-standard.org/standard/core/BracketCHAR#reply-97 `------------------------------------------ Sorry, I could've sworn the previous implementation isn't there. Please ignore. ,------------------------------------------ | 2018-01-08 15:52:01 alextangent replies: | referenceImplementation - Suggested reference implementation | see: https://forth-standard.org/standard/core/HEX#reply-98 `------------------------------------------ 1. This is not a correct definition; the closing ; is missing. 2. It will only compile correctly if the 16 is interpreted as a decimal number, which the definition does not ensure. ,------------------------------------------ | 2018-01-08 15:54:04 NieDzejkob replies: | referenceImplementation - Suggested reference implementation | see: https://forth-standard.org/standard/core/BracketTick#reply-99 `------------------------------------------ Sorry, my Forth is slightly non-standard in that regard. ,------------------------------------------ | 2018-01-08 16:03:12 NieDzejkob replies: | referenceImplementation - Suggested reference implementation | see: https://forth-standard.org/standard/core/FILL#reply-100 `------------------------------------------ `: FILL ( c-char u char -- ) ROT ROT 0 ?DO 2DUP C! CHAR+ LOOP 2DROP ;` The `ROT ROT` does not seem right to me, but finding anything better has proven not to be simple. ,------------------------------------------ | 2018-01-08 16:12:00 NieDzejkob replies: | referenceImplementation - Suggested reference implementation | see: https://forth-standard.org/standard/core/TYPE#reply-101 `------------------------------------------ `: TYPE ( c-addr u -- ) 0 MAX 0 ?DO DUP C@ EMIT CHAR+ LOOP DROP ;` Alternatively, without `?DO` or `LOOP`: `: TYPE ( c-addr u -- ) BEGIN DUP 0> WHILE OVER C@ EMIT [ -1 CHARS ] LITERAL - SWAP CHAR+ SWAP REPEAT 2DROP ;` ,------------------------------------------ | 2018-01-08 16:12:31 alextangent replies: | referenceImplementation - Suggested reference implementation | see: https://forth-standard.org/standard/core/TYPE#reply-102 `------------------------------------------ : TYPE 0 MAX 0 ?DO DUP C@ EMIT 1+ LOOP DROP ; should read : TYPE ( c-addr u -- ) 0 MAX 0 ?DO DUP C@ EMIT CHAR+ LOOP DROP ; There are several problems with (even the corrected version) as a reference implementation. The biggest issue is that it doesn't permit using the XCHAR wordset. The primitive for output there is XEMIT, and there is no equivalent XTYPE. The extension says "All words dealing with strings shall handle xchars when the xchar word set is present." It may be that there is no reference implementation in terms of standard words possible. ,------------------------------------------ | 2018-01-08 18:42:05 NieDzejkob replies: | referenceImplementation - Suggested reference implementation | see: https://forth-standard.org/standard/core/CComma#reply-103 `------------------------------------------ Nope, this won't work, since `HERE` is more like a VALUE than a VARIABLE in ANS Forth. Why is standarization so hard? ,------------------------------------------ | 2018-01-08 19:09:21 alextangent replies: | referenceImplementation - Suggested reference implementation | see: https://forth-standard.org/standard/core/CComma#reply-104 `------------------------------------------ ``` : c, ( n -- ) here c! 1 chars allot ; ``` You're now running into chicken and egg problems. There aren't reference implementations for everything; some things are primitives qv `DUP`. You might want to stand back and work out those words that justify a reference implementation because they provide an explanatory point, and those that don't because they might be considered self evident. I'd contend that you've reached that point. ,------------------------------------------ | 2018-01-08 19:18:53 alextangent replies: | referenceImplementation - Suggested reference implementation | see: https://forth-standard.org/standard/core/FILL#reply-105 `------------------------------------------ Consider not using `?DO` ``` : FILL ( c-addr u char -- ) >R BEGIN DUP 0<> WHILE OVER R@ SWAP C! 1 /STRING REPEAT R> DROP ; ``` ,------------------------------------------ | 2018-01-08 19:26:17 alextangent replies: | referenceImplementation - Suggested reference implementation | see: https://forth-standard.org/standard/core/TYPE#reply-106 `------------------------------------------ Addendum; and the use of `0 MAX` is not correct, as the length of the buffer is unsigned.