you should be able to just remove the ref in Token = ref object. That is one 
layer of indirection less, and therefore faster and less memory consumption. 
And a little comment on what you are doing. Tokens are not nested. What you are 
doing is already parsing. In brainfuck all tokens are characters, so 
tokenization is basically irrelevant.

And the last part is setting current and latest. That is a very dirty way of 
programming. As soon as programs become more complex you will no longer know 
what side effects your functions have. It is better if you find a way to encode 
current and latest as arguments and return values. You don't need any mutable 
state, if you return at the top level a nested Token instead of seq.

You should know that none of these recommendations are special Nim style, they 
are good programming style in general.

Reply via email to