On 2-Apr-09, at 5:59 PM, Per Eckerdal wrote:
But I still don't see any error in the main point of my previous mail, that is that only two different sets of globals are needed.
No... that's wrong.
Haha I have seriously spent since I read your last mail (40mins) to try to understand that, but I finally think I do. Bummer.
It just doesn't feel good to have to resort to things with such great conceptual and performance overhead.
I too like simplicity. But is there an easy model (to implement) that is also elegant and powerful? The easier models I know are less elegant than the syntactic tower model.
How many levels are really used in practise, assuming that Gambit core can somehow be hacked away from this limitation? I don't think I've ever seen a macro that uses complex macro expansion in itself, let alone more levels. If interpretation with a cache with macro- expanded code for each used level is used mostly, wouldn't that work rather well? I can see libraries like srfi-1 needing to be instansiated at levels 1, 2 and maybe 3 but that's an extreme case. For these libraries it might be possible to add a declaration that states that multiple instances of this module is not required?
I appreciate your desire for a model that is easy to implement, but the kind of questions you are asking suggest to me that the end product will be a model that isn't pure. In other words it will work 90% of the time (hey maybe 99% of the time), but in those 1-10% of the time when it breaks down the user has no clue what he has done wrong. Let's not forget why we like Scheme! The elegance of the model must prevail over implementation complexity and performance (as long as it is not too complex or slow, as Einstein might put it).
A more impure approach might be to require modules that require multiple instances to declare that explicitly. As I understand it most modules don't carry any state at all, and in these cases this isn't an issue. (With state I mean anything that isn't constant or isn't the same for every invocation of the module)
It is not just a question of state. Each instance of a module must go through an initialization phase (i.e. the phase when the "define"s and the top-level expressions of the module are executed). What if a module contains this definition
(define start-time (current-time))
or
(define unique-id (random-integer 1000000000000000))
or
(define t (thread-start! (make-thread (lambda () ...))))
or
(define v (list 1 2 3))
In all of these cases it may be important to run the initialization phase for each instance of the module, to get a correct start-time of the instance, a unique identifier for that instance, a thread per instance, or unique objects for each instance (to distinguish them with eq?).
Marc