,---------------.
| Contributions |
`---------------´
,------------------------------------------
| 2022-04-05 14:05:53 JimPeterson wrote:
| referenceImplementation - Possible Reference Implementation
| see: https://forth-standard.org/standard/core/VARIABLE#contribution-232
`------------------------------------------
Would the following be a viable reference implementation?
```
: VARIABLE ALIGN HERE 0 , CONSTANT ;
```
Of course... this initializes the contents, and you might not want to imply that such is required in an implementation. So maybe this more verbose definition:?
```
: VARIABLE ALIGN HERE 1 CELLS ALLOT CONSTANT ;
```
,------------------------------------------
| 2022-04-05 14:43:43 JimPeterson wrote:
| referenceImplementation - Possible Reference Implementation
| see: https://forth-standard.org/standard/core/MIN#contribution-233
`------------------------------------------
I'm not sure of the value of reference implementations for such simple words, but here's one:
```
: MIN 2DUP < IF DROP EXIT THEN NIP ;
```
... there's also an equivalent for MAX:
```
: MAX 2DUP < IF NIP EXIT THEN DROP ;
```
But hen, NIP is in CORE-EXT, and providing a reference for a CORE word that uses words from CORE-EXT may seem invalid, so would these be more preferred?:
```
: MIN 2DUP > IF SWAP THEN DROP ;
: MAX 2DUP < IF SWAP THEN DROP ;
```
,------------------------------------------
| 2022-04-05 17:44:08 JimPeterson wrote:
| example - Possible Reference Implementation
| see: https://forth-standard.org/standard/core/ALIGN#contribution-234
`------------------------------------------
Just taking a stab at this:
```
: ALIGN HERE ALIGNED HERE - ALLOT ;
```
,---------.
| Replies |
`---------´
,------------------------------------------
| 2022-04-05 07:21:20 AntonErtl replies:
| requestClarification - Double>
| see: https://forth-standard.org/standard/core/MTimes#reply-814
`------------------------------------------
`$7FFFFFFFFFFFFFFF 1 lshift` produces `$FFFFFFFFFFFFFFFE` (on a 64-bit system).
`$7FFFFFFFFFFFFFFF 1 lshift 0` produces `$FFFFFFFFFFFFFFFE 0`.
I.e., the right side of the test case produces the values that you correctly identified as correct answer.
,------------------------------------------
| 2022-04-05 12:53:09 AdrianMcMenamin replies:
| requestClarification - Double>
| see: https://forth-standard.org/standard/core/MTimes#reply-815
`------------------------------------------
Thank you for the clarification but can I suggest that, if at all possible, the formatting of the test answer is changed? It looks very much like there are two groups here and the second is "1 LSHIFT 0" which obviously makes no sense as Forth but which I assumed meant 1 shifted left by zero (ie 1). Perhaps that is my mistake, but the formatting encouraged me in it.
,------------------------------------------
| 2022-04-05 15:03:31 JimPeterson replies:
| referenceImplementation - Suggested reference implementation
| see: https://forth-standard.org/standard/core/HEX#reply-816
`------------------------------------------
With `DECIMAL`, you could:
```
BASE @ DECIMAL : HEX 16 BASE ! ; BASE !
```
... but then it's difficult to define `DECIMAL` (without `HEX` or `BIN`).
The best I could come up with for the entire set is:
```
BASE @ \ remember it ...
1 2* BASE ! \ get to binary
: BIN 10 BASE ! ;
: DECIMAL 1010 BASE ! ;
: HEX 10000 BASE ! ;
BASE ! \ ... and restore it
```