-
Notifications
You must be signed in to change notification settings - Fork 37
The whitespace interpreter written in whitespace is broken. #5
Comments
Though it seems reasonable that such accesses are undefined behavior, I'm not sure the C++ implementation (or any) is considered "canon" enough to guide expectation. One might argue that the whitespace interpreter written in whitespace is more "famous" outstanding code, hence interpreters should adapt to its expectations... (?) Beats me. I'd take a PR for wsinterws.ws to just work around it. But if you want to have some fun you might try and get a formal statement from the authors of the specification about this case. |
Considering the C++ version triggers undefined (as in C++ undefined) behaviour when you try to retrieve an element from the heap with a key larger than any key that has previously been stored in it, I'd say it should definitely be considered undefined behaviour. I'll see if I can find where the error in wsinterws.ws lies (or just badly patch it by setting the value of the key at the start). I've got a feeling that if I try getting a formal statement about it it'll end up like this |
I've spent enough time around language specifications to know that the behavior of one implementation of a language (especially when not written by the authors of the spec) does not dictate the semantics of the language. If you can make contact with the original spec authors to clarify the point and have them update it in their document, that would be ideal. (Not pointless...people actually do use these languages for teaching exercises, programming puzzles and games, etc.) I don't know if you mean the C++ version that wound up in this repository but there's apparently another one now whitespace-interpreter. I suppose I should add that as a submodule here, perhaps even replacing the old one I found. |
Just noting it down here: simply setting heap[6] to 0 at the start of wsinterws.ws doesn't work as it will encounter other missing keys during operation (these keys depend on the program being interpreted and are generally in higher heap regions (I've seen 48035, 1458247) on some example programs. |
I've tried to contact him but as so far no response. Anyway, this might be of interest to you. |
I'm archiving this repository due to a more vetted and active project to collect interpreters. https://github.com/wspace/corpus The person doing this (@andrewarchi) may have more to say about this kind of detail, so maybe good to take this issue there if you still have feelings about it. :-) |
When attempting to run wsinterws on an interpreter which faults on retrieves of keys that have not been set, wsinterws.ws will fail to run as it tries to retrieve item 6 from the heap while it has never been set. As the C++ based interpreter does not check for this accurately (as its heap model is just a continuous array that gets resized to fit the largest item put in there).
The text was updated successfully, but these errors were encountered: