3 ms·
This sounds a bit like cheating. What if you want to parse a really big file and delete the tokens as soon as you don't need them? If Rust claims to solve memo
by amelius 5y ago
This sounds a bit like cheating. What if you want to parse a really big file and delete the tokens as soon as you don't need them?
If Rust claims to solve memory management, then we should not fool ourselves by allocating everything in a huge chunk which is then freed when the program ends.
- steveklabnik 5y agoIf this is cheating, many real compilers “cheat.” Heck, some of them famously don’t even free it when the program ends, leaving that up to the operating system!
- amelius 5y agoThe solution doesn't scale. The moment you need to deal with very large inputs, you will have to rewrite your entire application from scratch.
- scns 5y agoI prolonged my own path many times in my life, by making things harder than they need to be. (edit) Aspirations acting as a anti-shortcut somehow.
- brabel 5y agoThat's why this was not my first choice... but it was just far too hard to implement it otherwise... and then again, once you really think about it, you must keep ALL tokens/AST nodes in memory to be able to analyse and type-check/lint any decent language... so keeping a big Sring in memory while all nodes just point to slices of it is not nearly as wasteful as it might appear at a first glance.