4 ms·
No, it's nothing like that. It's a method for implementing interpreters that works well for Forth. It has absolutely nothing to do with 'spaghetti code' or stru
by talideon 5y ago
No, it's nothing like that. It's a method for implementing interpreters that works well for Forth. It has absolutely nothing to do with 'spaghetti code' or structured programming.
In this case, the term 'thread' is the same in both usages. The confusion is that people started using 'multithreading' and 'threading' interchangeably. The concept of a 'thread' existed before Forth and any form of multitasking were invented, and MVT (which used the term 'task' rather than 'thread') and Forth were both invented around the same time.
I'd recommend you read the Wikipedia page for 'Threaded code': it's much clearer than the linked page, and will give some background of the purpose behind it. Most interpreters that don't do something like walking an AST do some form of it, even if that's by using some kind of bytecode. If you've ever seen code written using continuation-passing style, it's implementing a form of threaded code.