It just occurred to me that an invocation (say, of a method in Java) is in fact an instance of a special, eh, type.
More precisely, each invocation creates a frame on a JVM stack, which contains all the data necessary for execution of the call. It just happens that the only references to these frames are located on the JVM stack. This fact allows simplifying garbage collection of the frames, namely they are discarded immediately after return from the call.
I tried to imagine what kind of a language (or VM) would result if there were no JVM stack, or rather if it were explicitly in the control of an application developer and/or compiler.
The first thing to come to mind are tail-call optimizations. Well, not optimizations at compile-time, but run-time possibility to garbage collect frames to which no-one will return.
The second: as thread-specific storage is deprived of the stack, it basically is left with pc (program counter?). Could it enable cheaper multi-threading?
The third: coroutines? If application can explicitly handle frames... Well, I cannot stop my fantazy :)
Could the honorable audience give me some pointers to close ideas in existing/hypothetical languages/run-times/formalisms? Am I just obsessed by some well-known and trivial notion? Words like 'closure' are buzzing in my mind, but I cannot grasp them.
Major thanks! :)
If I understand what you're suggesting (and I'm not sure I do), I think "first-class continuations" might be the magic phrase you're looking for. Even if that's not quite what you have in mind, reading some of the copious literature on the subject might help clarify your own idea...
I don't know of a good intro to continuations, but I imagine someone else here could provide a link. Scheme is maybe the most prominent language that features first-class continuations, and you could almost certainly find more info either at the readscheme.org continuations page (but note that "continuation-passing style" or CPS is a related but somewhat different topic) or in the docs for any of the big Scheme implementations (maybe look for call/cc or call-with-current-continuation).
Have fun!
Historically, objects were invented in Simula as a generalization of the activation records of BEGIN...END blocks.
/s
It may help if you draw pictures for yourself, since not everyone thinks in Scheme. ;)
SML/NJ's implementation puts all its frames on the heap.
I happenned to find most of the papers mentioned even before I saw the posts - just directing me to Scheme was very productive :) Google is great, SiteSeer coming next to it (him? :))...
The only thing I could not find was "Viewing control structures as patterns of passing messages". And I really miss it after reading its abstract :( Darius, are you aware of its online version?
Ah, I also had a real fun reading Stackless Python mailing list archives - all the polytical/ideological/psychological intricacies being not less amusing than technological discussions. Looks like SLP 1.0 is (was) very close to what I had in mind several days ago... Could not find any SLP 3.0 papers - are these mystical tasklets somehow related to pi calculus family? Any experts?
Unfortunately, now I believe none of the magic I imagined can be effectively done on top of a standard JVM... That really precluding me from continuing this way full-time :( Business world is harsh...
But thank you all, it was real fun, keeping me long hours after midnight :)