2010/4/21 Peter Hugosson-Miller <oldmanlink@gmail.com>:
Hi all, So it's time for me to stop lurking and do some stuff. However, although I am an experienced Smalltalk programmer (VisualAge Smalltalk continuously since 1995), I am a complete newb when it comes to Pharo and Squeak, it's hard to find my way around, and it's going to take me some time to get up to speed. I'm working on a small improvement to the testing framework, using ideas that I have found to be very useful in my daily job over the past 15 years. Note that I am doing this from scratch, so that I don't accidentally steal anything that I've done in my work, but I know how it all works in VisualAge, so I feel sure that I'll eventually be able to find the corresponding classes and methods in Pharo. What I would like are a few hints, clues and nudges in the right direction for scenarios and questions that I will describe in this thread. What I *don't* want are full-blown solutions, because then I won't learn anything. I hope that some kind souls will be able to give me a little help in the beginning that will eventually bring me up to speed and let me be productive. So to start with, one scenario and one question: 1) I want to find or write a method on Process that will print a stack trace onto a supplied Stream. Ideally I'd like to be able to decide the start and stop depth of the trace, so for example if I know that the top 4 stack frames will always be uninteresting, I would want to be able to write something like this: Â Â Â Â Processor activeProcess printStackFrom: 5 to: 15 on: aStream. 2) What *exactly* is "thisContext"? It appears to be a reserved word in Pharo, just like the familiar "self", "super", "true", "false", "nil" that are always reserved in Smalltalk. I'd also like to get an idea of what it's good for, and if anyone can describe it in terms of something that is in VisualAge, that would be nice too :-)
thisContext is a special object for representing an activation in a stack frame in a stack-based VM. There are two kinds of contexts: Method Contexts and Block Contexts. Context creation is optimized in the VM in most Smalltalks, so it's only really created as an object in the environment (reified) when it's specifically needed through "thisContext". You may emulate its usage in VisualAge writing something like [] homeContext and in a method it would be
thisContext "returns the context of the sender" ^[] homeContext sender
although with some limitations. There are several applications related with computational reflection (Reflective Programming, Meta-Programming, MOP, etc) which makes use of the current context. Cheers, Hernán
BTW, if this is not the appropriate place for a thread like this, then please tell me where I should put it (politely, of course :-p) -- Cheers, Peter
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project