Skip to content

Instantly share code, notes, and snippets.

@StephanEggermont
Created November 22, 2013 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StephanEggermont/7598946 to your computer and use it in GitHub Desktop.
Save StephanEggermont/7598946 to your computer and use it in GitHub Desktop.
Pharo now uses slots to describe instance variables. Booleans no longer need to be separate instance variables, several can be mapped to a bit in one instance variable. Printing this in a workspace returns the set of classes having instances with more than one boolean instVar. It doesn't detect lazy initialized ones, or classes with no current i…
|set|
set := IdentitySet new.
Object allSubclasses do: [ :aClass |
|varSize coll nr candidate |
candidate := false.
varSize := aClass instSize.
coll := aClass allInstances.
nr := 10 min: coll size.
(coll first: nr) do: [ :anInstance |
|value nrBoolean|
nrBoolean := 0.
1 to: varSize do: [ :varIndex |
value := anInstance instVarAt: varIndex.
value class = True ifTrue: [ nrBoolean := nrBoolean + 1 ].
value class = False ifTrue: [ nrBoolean := nrBoolean + 1 ]].
nrBoolean >1 ifTrue: [ candidate := true ] ].
candidate ifTrue: [ set add: aClass ]].
set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment