On 16-2-2013 3:34, bearophile wrote:
A first revision, do you like the toString?

http://codepad.org/qhH2XpMx


It's fine, but we need another write at the end of run otherwise the final state
doesn't get written.

The modified code contains still an enum that gets converted to char and then 
to int.
I am not going to write code like that in my own "production code" :-)

- - - - - - - - - - -

To improve this type soup a bit I suggest to introduce one or more alias for 
the types of states, etc, like:

alias State = char;


Good idea. I'll change that.

I'm still not happy with the TuringMachine creation although it looks
more organized than before.

I'm thinking about putting the definitions in xml, then have a parser
create an immutable TuringMachine that we can then pass to UTM. That
would also take care of the nested AA problem. The rules object can
then have a tuple or a struct.

BTW, the reason I used a class is that it forces you to instantiate through
the constructor.

If you use a class and write:

(new UTM().run()); // fails at compile time

If you use a struct and write:

UTM().run(); // fails at runtime


Reply via email to