3 ms·
I've done some work on the read_token function. The implementation on the site has some problems. * The string conversion to chstr is unnecessary. Rune compari
by exch 14y ago
I've done some work on the read_token function.
The implementation on the site has some problems.
* The string conversion to chstr is unnecessary. Rune comparisons can be done simple with `ch == '('`.
* The 128 byte buffer will cause a panic when you enter an atom that exceeds this size. The idiomatic way to do this, is to use a `bytes.Buffer` instance.
* There is also an extra error check in the rune reading loop. The original ignored possible EOF's. Not sure how relevant it was in this particular use case, but just ignoring errors outright is never a good idea.
https://gist.github.com/2551271 https://gist.github.com/2551271
- regularfry 14y agoFab, thanks for that. Not sure how I picked up the idea that a string( chstr ) was needed there. As far as error checks go - yeah, there are many places I spotted on the way through where errors might happen that neither the original nor my version are checking for. I'll have another shot at it and see what I can clean up at some point in the week.