English 中文(简体)
How to find the current stack?
原标题:

in Pharo, how can I find the currently evaluating stack?

最佳回答

Well, in fact, the issue aint that simple: thisContext can be a quite expensive operation, compared to like a message send.

In Visualworks Smalltalk, stack access is extermly expensive because it uses the native C-stack and thus any access to thisContext must reify the entire C-Stack into causally connected Smalltalk objects. That is, for each C stack frame a Smalltalk object is to be created (including possible JIT deoptimization) and furthermore all changes to these objects must be reflected back to the C stack.

In Pharo (and Squeak, for that matter) it is less awkward, since it uses Smalltalk objects for the stack. But still the object pool which caches stack frames is flushed upon each call. (Yes, other than eg in Java, pooling objects does improve performance in Squeak ... welcome back to the 90ies :)

问题回答

You evaluate

thisContext contextStack

Here, thisContext is really a special variable that points to the currently active stack frame. Then, contextStack returns an array with the entire stack.





相关问题
How do you set the class of an object to something else?

I ve seen this recently and now I can t find it … How do you set the class of an object to something else? --Update: Well, in Pharo! Like: d:=Object new. d setClass: Dictionary. Only that it isn ...

Using Polymorphic Code for Legitimate Purposes?

I recently came across the term Polymorphic Code, and was wondering if anyone could suggest a legitimate (i.e. in legal and business appropriate software) reason to use it in a computer program? ...

How can I get this snippet to work?

I d like to port a little piece of code from Ruby to Groovy, and I m stuck at this: def given(array,closure) { closure.delegate = array closure() } given([1,2,3,4]) { findAll { it > 4} ...

Why can t I use attr_accessor inside initialize?

I m trying to do an instance_eval followed by a attr_accessor inside initialize, and I keep getting this: ``initialize : undefined method attr_accessor `. Why isn t this working? The code looks kind ...

热门标签