3 ms·
A third stack is one more thing to keep track of. The simpler solution to this in many languages is type tagging. E.g. Ruby (MRI at least) uses a few bits to i
by vidarh 6y ago
A third stack is one more thing to keep track of.
The simpler solution to this in many languages is type tagging. E.g. Ruby (MRI at least) uses a few bits to indicate type to avoid creating full-blown objects for small-ish integers, symbols, etc., and you'll find the same approach in many strongly typed dynamic languages.
- js8 6y agoI think you misunderstand. The 3rd stack would be parallel to data stack, and would be used during interpretation for dynamic type checking (and also completion), or during compilation to do static type checking (and also type inference).
- vidarh 6y agoI got that. The point I was making is that type tagging is an alternative to this that saves you from keeping the extra stack in sync, as well as avoids sacrificing another register as a stack pointer. It's also well trodden ground in the form of tagged unions of various forms going back at least to ALGOL 68 so there's plenty of literature on the subject.