[squeak-dev] List of all global variables? (Environments?)

H. Hirzel hannes.hirzel at gmail.com
Mon Apr 3 18:03:23 UTC 2017


Found the solution. It is in the class comment of SystemDictionary


_____
I represent a special dictionary used as global namespace for class names :

	Smalltalk globals classNames.

and for traits too:

	Smalltalk globals traitNames.
	
and a few other globals:

	(Smalltalk globals keys reject: [:k | (Smalltalk globals at: k) isBehavior])
			collect: [:k | k -> (Smalltalk globals at: k) class].

As the above example let you guess, the global namespace of Smalltalk
system is accessed through:

	Smalltalk globals.

____
I updated http://wiki.squeak.org/squeak/1824
__
However there is a problem with

    (Smalltalk globals reject: [:each | each class isMeta]) inspect


You get the list but if you click on 'self' then you get a different
list. (printString issue)




On 4/3/17, H. Hirzel <hannes.hirzel at gmail.com> wrote:
> P.S. A more elegant solution is mentioned at the bottom of page
> http://wiki.squeak.org/squeak/1824
>
> Smalltalk globals reject: [:each | each class isMeta]
>
> Result attached.
>
>
>
> For that to work Environment needs the addition of
>
> reject: aBlock
> 	^ declarations reject: aBlock
>
> in the 'emulating' instance method protocol
>
> On 4/3/17, H. Hirzel <hannes.hirzel at gmail.com> wrote:
>> Hello
>>
>> The recipe: How to list all global variables [1]
>>
>> has the code snippet
>>
>>
>>
>>     Smalltalk keys
>>     select:
>>     [:k | ((Smalltalk at: k) isKindOf: Class) not]
>>        thenCollect:
>>       [:k | k -> (Smalltalk at: k) class]
>>
>>
>> to give a list of global variables.
>>
>>
>> When executing this code the recommendation is to use
>>
>>     Smalltalk globals
>>
>> instead of
>>
>>     Smalltalk keys
>>
>>
>> A  rewrite because of Environments not having #select:thenCollect:  (I
>> do not think that is necessary) then is
>>
>>     (Smalltalk globals select: [:k | ((Smalltalk at: k) isKindOf: Class)
>> not])
>>        collect:  [:k | k -> (Smalltalk at: k) class]
>>
>> Then I get 'key not found: ExtendedNumberParser'.
>>
>> I wonder what is going on here ...
>>
>> Regards
>> Hannes
>>
>>
>> [1] http://wiki.squeak.org/squeak/1824
>>
>


More information about the Squeak-dev mailing list