4 ms·
I wrote a Lisp reader for C a long time ago: https://github.com/schani/lispreader https://github.com/schani/lispreader An interesting problem that came up was
by mark-probst 6y ago
I wrote a Lisp reader for C a long time ago: https://github.com/schani/lispreader https://github.com/schani/lispreader
An interesting problem that came up was freeing deeply nested conses without overflowing the stack. I got a bug report about that from a user. They must have generated the structure in memory, because if they were reading it in, the reader would probably also have overflown the stack. In any case, the simple solution was to rotate the structure to be freed so that it can be freed without stack overflow or using an additional queue or stack:
https://github.com/schani/lispreader/blob/master/lispreader.c#L566 https://github.com/schani/lispreader/blob/master/lispreader....