nixpulvis / brainfuck

A simple brainfuck interpreter in Rust.
http://nixpulvis.com/brainfuck
23 stars 3 forks source link

Wrapping Numerics #2

Closed nixpulvis closed 8 years ago

nixpulvis commented 8 years ago

We want the values on the tape, and the value of the pointer to wrap in our language. Bound checking isn't something brainfuck should do IMO.

nixpulvis commented 8 years ago

Worth noting, the ergonomics of Wrapping are not great, but it is nice to see them explicitly.

offlinemark commented 8 years ago

I get this output when I try to run hello.b

mark macbook ~/c/l/r/brainfuck ((85c88d0...)) ❯ cargo run fixtures//hello.b
     Running `target/debug/brainfuck fixtures//hello.b`
hXXX WWW
nixpulvis commented 8 years ago

In testing these things it's key to play with and without the --release flag. Also it'd be great to get a sense of what semantics we really want exactly. I'm pretty happy with having both the values and the pointer be wrapping numbers, but I can also see merit in bound checking the pointer explicitly.

nixpulvis commented 8 years ago

Yea this is clearly not a working implementation ATM is it lol. Should add a test for whatever the fuck I broke. I was mostly avoiding writing tests that mock STDIN/STDOUT.

nixpulvis commented 8 years ago

Rebased maser with new testing output of programs, and we're catching this bug now.

nixpulvis commented 8 years ago

Now we just need to implement something like Wrapping for wrapping to the size of the tape. Again, now the more I think about it the more I'm liking checking the pointer at runtime.

nixpulvis commented 8 years ago

@mossberg do you have any thoughts on the best course of action for wrapping? I'm thinking about adding an error type for runtime errors and having one returned in these cases.

nixpulvis commented 8 years ago

FWIW: http://www.muppetlabs.com/~breadbox/bf/standards.html

nixpulvis commented 8 years ago

Merging this as it for now. Might look back at this later in another PR.