Hi, To make it easier to refactor these places, here is how to find asClass usages with GTSpotter: http://www.humane-assessment.com/blog/finding-asclass-usages-in-glamour-using-gtspotter
:) Cheers, Doru On Wed, Apr 8, 2015 at 12:32 PM, stepharo <steph...@free.fr> wrote: > Hi > > We want to raise a strong warning against the extension of the use of > asClass and friends. > asClass should not be used in Pharo distribution. I will propose to > deprecate it. > > We are working on dependency analysis, module system, remote debugging and > asClass introduces > lose class references and many related problems. > > I would like to remove this behavior because it is clear that it will just > grow up and lead to deadcode and ugly dependencies. > > First, most of the time you can avoid to query Smalltalk globals at: and > that BY CONSTRUCTION a software system should be built and it should > define its own customization. > > > Second, at least use self class environment at: #foo > > Why is it much much much better? because it does not rely on String class > resolution and as such > is much more modular. You do not want to have the resolution of a symbol > related to the place where String is defined but on where your code is > actually. > > Imagine that tomorrow your code is in its own module. Then you want to > know from your code point of you > if a binding exist not from the one of environment in which String is. > > > > > here are some examples: > > ============================== > quadrangleClass > ^ 'QuadrangleForTesting' asClass > > Strange it simply breaks. Of course it broke the smallLint rule. > > ============================== > Metacello should better define OSProcess as a dependent.Because it is not > clear what will happen > if if not there? > > extractRepositoryFrom: zipFile to: directory > "unzip <zipFile> into <directory>" > > | out err proc errorMessage | > out := FileStream forceNewFileNamed: '/tmp/zip.out'. > err := FileStream forceNewFileNamed: '/tmp/zip.err'. > errorMessage := ''. > [ > proc := #OSProcess asClass thisOSProcess > forkJob: '/usr/bin/unzip' > arguments: > {'-u'. > zipFile. > '-d'. > directory} > environment: nil > descriptors: (Array with: nil with: out with: err). > > ================== > > I do not get why we need this funky logic. > > openInBrickWindowLabeled: aLabel > > #GLMSystemWindowBrick asClassIfAbsent: [ > ^ self asMorph openInWindow ]. > > ^ #GLMSystemWindowBrick asClass new > label: aLabel; > color: Color transparent; > addBrickBack: ( > GLMBrick new > vSpaceFill > > > window > "Answer the receiver's window." > #GLMWindowBrick asClassIfAbsent: [ > ^ self ownerThatIsA: SystemWindow ]. > > ^ (self ownerThatIsA: #GLMWindowBrick asClass) > ifNil: [ self ownerThatIsA: SystemWindow ] > > > > sendUsageData: aBoolean > | settingsClass | > settingsClass := #GTSpotterEventRecorderSettings asClassIfAbsent: [ ^ > self ]. > ^ settingsClass sendUsageData: aBoolean > > > sendUsageData > | settingsClass | > settingsClass := #GTSpotterEventRecorderSettings asClassIfAbsent: [ ^ > false ]. > ^ settingsClass sendUsageData > > > -- www.tudorgirba.com "Every thing has its own flow"