3 ms·
Not from the README. I don't read READMEs. I read code. The issue is this: > (1 2 3) 4 push My expectation is this should yield "(1 2 3 4)". It doesn't. For
by garmaine 7y ago
Not from the README. I don't read READMEs. I read code.
The issue is this:
> (1 2 3) 4 push
My expectation is this should yield "(1 2 3 4)". It doesn't. For that you need the following:
> (1 2 3) copy 4 push
Why is copy necessary here?
- codr7 7y agoStacks are reference types, the operation doesn't produce any new values. Half the time you want it there to push more items, or to display it in the REPL like in this case, but the other half you're going to drop it anyway. I'm still undecided on the stack ops. There is one case in forthy2 where a reference is left on the stack, and that is splicing values into forms [0], where it's more likely you want to keep working with the same form. More likely is not a very good heuristic for designing API's though, so I might just go with the behavior you expected. [0] https://github.com/codr7/forthy2#quoting https://github.com/codr7/forthy2#quoting
- codr7 7y agoFor the record, this should now work as expected without copying.