Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

The whitespace interpreter written in whitespace is broken. #5

Closed
CensoredUsername opened this issue Oct 5, 2016 · 6 comments
Closed
Assignees

Comments

@CensoredUsername
Copy link

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).

@hostilefork
Copy link
Owner

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.

@CensoredUsername
Copy link
Author

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

@hostilefork
Copy link
Owner

Considering the C++ version ... I'd say it should definitely be considered undefined behaviour.

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.

@CensoredUsername
Copy link
Author

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.

@CensoredUsername
Copy link
Author

I've tried to contact him but as so far no response. Anyway, this might be of interest to you.

@hostilefork
Copy link
Owner

hostilefork commented Jul 5, 2021

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. :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants