|
|
|
|
|
by waltpad
2233 days ago
|
|
My guess is that: 1) the quicksort algorithm which was used was a recursive version, and relied on local variables to do its job. 2) in the discussed BASIC implementation, local variables are translated to global variables (probably with some form of prefixing based on the function using it to avoid name clashes). This means that functions in that language are never fully reentrant, and that somehow an explicit variable stack has to be implemented to recover the ability to recurse without overwriting variable prematurely. Note: I initially had a doubt wrt reentrancy, as I had knowledge of this concept in the context of multithreading (I think it actually came up originally in that context), and indeed having concurrent uses of the same function relying on some global variable is problematic, but here there isn't any kind of concurrency. However, global variables can be a problem in the situation outlined above. Another possible issue, although not present here, is when a function F uses a global variable, and accept a function pointer. If that pointer is pointing to a function making a call to F somehow, then lack of reentrancy could also be a problem. To refresh my memory, I must admit that I had a quick glance at stackoverflow (https://stackoverflow.com/questions/3052393/reentrancy-and-r...). |
|