[aida] Superpowers: Climbing on the Stack in Aida/Web
janko.mivsek at eranova.si
Sat Sep 13 11:27:42 CEST 2008
http://smalltalk-superpowers.org, good idea indeed!
Here is my contribution from Aida/Web Smalltalk Web Application Server.
Please feel free to correct grammar and also ask me for better
explanation if you found something not clear enough. Also, I won't be at
OOPSLA, so we need to find a presenter ...
"Climbing on the Stack" in AIDA/Web
AIDA/Web is web framework and application server where quite a few
Smalltalk reflection techniques are used for maintaining the simplicity
of the framework. One is finding a reference to the web session in
context of which we are building a web page. To avoid having session
parameter in every method call, the session can be found from the stack,
by help of pseudo variable thisContest and we are calling this technique
"climbing on the stack".
Here is the method (on Squeak):
| context |
context := thisContext.
[context notNil] whileTrue:
[(context receiver isKindOf: AIDASite)
ifTrue: [^context at: 3]
context := context sender].
This method is trying to find a first sender up in stack which is an
AIDASite and get a session reference from 3th parameter of the method
call to the AIDASite, which happens to be always:
#answer: anObject toGetOrPost: aRequest on: aWebSession
Of course this technique costs some time, so it is advised to use it
sparingly, where there is not other possibility to get a session and
where performance is not too important.
Smalltalk Web Application Server
More information about the Aida