[squeak-dev] The Inbox: Compiler-ct.418.mcz

Levente Uzonyi leves at caesar.elte.hu
Sun Feb 16 23:31:48 UTC 2020


Hi Christoph,

On Sun, 16 Feb 2020, Thiede, Christoph wrote:

> 
> Hi Levente,
> 
> 
> actually, I love the Dictionary API with the #ifPresent:ifAbsent: arguments as it is very convenient for describing the code paths (IMHO). As you may have seen, I am trying to establish it for more domains
> (see Collections-ct.873, Collections-ct.872, Collections-ct.875).
> 
> 
> If you think it is important to distinguish between classes and globals, maybe we should also introduce #classNamed:[ifPresent:][ifAbsent:] (three variants) to SmalltalkImage? But this would be a lot of "forwarding noise".

In my opinion, #classNamed: is fine as-is, because when the class is 
available, the method will return it, when it's not, you'll get nil. No 
other return values are possible.
It also supports metaclass lookup, which is not available via #at:*.

Levente


> 
> Best,
> Christoph
> 
> _________________________________________________________________________________________________________________________________________________________________________________________________________________________________
> Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Levente Uzonyi <leves at caesar.elte.hu>
> Gesendet: Sonntag, 16. Februar 2020 22:39:13
> An: squeak-dev at lists.squeakfoundation.org
> Betreff: Re: [squeak-dev] The Inbox: Compiler-ct.418.mcz  
> Hi Christoph,
> 
> The idea with Environments was to move away from the SystemDictionary API.
> It obviously didn't happen, but there's #classNamed: for class lookup by
> name. Actually #classNamed: was there with SystemDictionary too, but it
> was and still is underused.
> 
> Levente
> 
> On Sun, 16 Feb 2020, commits at source.squeak.org wrote:
> 
> > Christoph Thiede uploaded a new version of Compiler to project The Inbox:
> > http://source.squeak.org/inbox/Compiler-ct.418.mcz
> >
> > ==================== Summary ====================
> >
> > Name: Compiler-ct.418
> > Author: ct
> > Time: 16 February 2020, 3:49:08.315 pm
> > UUID: 3ca7ba74-6e8b-f64d-bc62-701ebc5df3e0
> > Ancestors: Compiler-eem.416
> >
> > Small refactoring: Use SmalltalkImage >> #at:ifPresent:ifAbsent:.
> >
> > =============== Diff against Compiler-eem.416 ===============
> >
> > Item was changed:
> >  ----- Method: Compiler>>evaluateCue:ifFail: (in category 'private') -----
> >  evaluateCue: aCue ifFail: failBlock
> >        "Compiles the cue source into a parse tree, then generates code into
> >        a method. Finally, the compiled method is invoked from here via  withArgs:executeMethod:, hence the system no longer creates Doit method
> >        litter on errors."
> >
> >        | methodNode method value |
> >        methodNode := self compileCue: aCue noPattern: true ifFail: [^failBlock value].
> >
> >        method := self interactive
> >                                ifTrue: [methodNode generateWithTempNames]
> >                                ifFalse: [methodNode generate].
> >
> >        value := cue receiver
> >                                withArgs: (cue context ifNil: [#()] ifNotNil: [{cue context}])
> >                                executeMethod: method.
> > +      ^ value!
> > -      ^ value
> > - !
> >
> > Item was changed:
> >  ----- Method: MethodNode>>asColorizedSmalltalk80Text (in category 'converting') -----
> >  asColorizedSmalltalk80Text
> >        "Answer a colorized Smalltalk-80-syntax string description of the parse tree whose root is the receiver."
> >
> >        | printText |
> >        printText := self printString asText.
> > +      ^ Smalltalk
> > +              at: #SHTextStylerST80
> > +              ifPresent: [:stylerClass | stylerClass new styledTextFor: printText]
> > +              ifAbsent: [printText]!
> > -      ^(Smalltalk at: #SHTextStylerST80 ifAbsent: [nil])
> > -              ifNotNil: [:stylerClass| stylerClass new styledTextFor: printText]
> > -              ifNil: [printText]!
> 
> 
>


More information about the Squeak-dev mailing list