"A recipe from Squeak wiki at http://wiki.squeak.org/squeak/1824
Smalltalk keys select:
[:k | ((Smalltalk at: k) isKindOf: Class) not]
thenCollect:
[:k | k -> (Smalltalk at: k) class]
"The code is in SystemDictionary's class comment."
Smalltalk implementations and VM's are evolving - but just compare what has to be done today in other dynamic languages to achieve the same ...
One notable exception is the Io Lobby object. With a little care, the same result can be very succinct in Rebol 2.7.6. and even simpler in Rebol3.
Here is a node.js shell result on startup:
for (var s in process) { s}In a Pharo One-Click I get an Array of 127 assocs.
'listeners'
Python does have dir(obj) which is hardly a Smalltalk inspection widget ...
in JavaScript there had been access to the Arguments object for a top-level function callee/caller to get into the activation/call object - But what will that kludge's fate be now that ECMAScript5 is here and Mozilla JavaScript 2.0 is coming?
In all fairness, in Smalltalk and Rebol the unwary traditionally can clobber anything. But in Smalltalk you can inspect almost anything non-primitive - even during startup. And a bootstrapping JavaScript interpreter written in JavaScript achieves almost the same transparency. See also: The avocado variant of Lively-Kernel.
see: JavaScript Function.call and Function.apply and ECMAScrip5 Function.prototype.bind
No comments:
Post a Comment