Conversation
So that it's consistent with C
Makes it so that generic code is skipped when moving up and down in the interactive command prompt
| `pick` reads and drops the number at the top of the stack, which we will call `n`, and copies the `n`-th element to the top of the stack. Example: | ||
|
|
||
| push1 push2 push3 push4 push2 pick | ||
| push1 push2 push3 push4 push1 pick |
There was a problem hiding this comment.
With the previous example the stack just remains the same after applying pick, this behaviour confused me a bit when following the tutorial so I decided to change it to an example that modified the stack so other people could appreciate the behaviour of pick better.
There was a problem hiding this comment.
Still, it may be easier for some people to follow the previous example so if this change is controversial i can revert it.
There was a problem hiding this comment.
With the previous example the stack just remains the same after applying pick
Really? 🤔 I have to check...
| Resulting stack: | ||
|
|
||
| {% include stack.html stack="1 2 3 4 2" %} | ||
| {% include stack.html stack="1 2 3 4 3" %} |
There was a problem hiding this comment.
Why change the example? This affected the result. Is it a better one?
There was a problem hiding this comment.
Consequence from the change in the example.
| Resulting stack: | ||
|
|
||
| {% include stack.html stack="1 3 4 2" %} | ||
| {% include stack.html stack="1 2 4 3" %} |
There was a problem hiding this comment.
Why change the example? Is it better?
There was a problem hiding this comment.
Changed it to remain consistent after changing the other example.
index.markdown
Outdated
| ### `pick` (opcode `0x79`) | ||
|
|
||
| `pick` reads `n` and copies `n`-th element to top stack. Example: | ||
| `pick` reads and drops the number at the top of the stack, which we will call `n`, and copies the `n`-th element to the top of the stack. Example: |
There was a problem hiding this comment.
Good idea.. I think that changing to pick consumes n could be even simpler. Phrase became too long.
There was a problem hiding this comment.
The issue that I came across when following the tutorial is that n is not defined anywhere so you have to end up guessing what it is by looking at the examples. I was trying to fix that with these changes.
There was a problem hiding this comment.
Perhaps: consumes top-stack value n...
There was a problem hiding this comment.
That's a great idea, I'll change it!
|
|
||
| To inspect what happened, use the following commands to get array from altstack and pick inside it: | ||
| `dupfromaltstack 0 pickitem` (gets first element), `drop`, `dupfromaltstack 1 pickitem` (gets second element). | ||
| `dupfromaltstack push0 pickitem` (gets first element), `drop`, `dupfromaltstack push1 pickitem` (gets second element). |
|
|
||
| function selectPreviousLine() { | ||
| if (selectedLine === null || selectedLine === 0) { | ||
| if (selectedLine === null || selectedLine === 233) { |
There was a problem hiding this comment.
If you go into one of the interactive prompts in the webpage and press the upper or lower arrow in your keyboard a generic forth script is displayed. This prevents that script from being displayed while still preserving the arrow functionality.
There was a problem hiding this comment.
Perhaps it's better to create a clearconsole function, so we clear past commands.
I haven't done it myself too hahah only used on github.io pages. Must see how to do this locally. |
|
Hi @igormcoelho, I was going through my open PRs and stumbled upon this. Is there something that I should change on this PR? I can also close it if you consider that it doesn't add enough value. |


I haven't built the website and tested it because I haven't been able to find the instructions on how to do it.