[squeak-dev] The Inbox: Tools-ct.945.mcz

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Tue Feb 25 17:33:50 UTC 2020


Is it nice to have an implicit ifNil: [nil] return value?

<http://www.hpi.de/>
________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Taeumel, Marcel
Gesendet: Dienstag, 25. Februar 2020 15:13:42
An: John Pfersich via Squeak-dev
Betreff: Re: [squeak-dev] The Inbox: Tools-ct.945.mcz

> I still feel like using #ifNil:, #ifNotNil: in a cascade is not right.

Me too. It's hard to read.

Best,
Marcel

Am 25.02.2020 11:36:00 schrieb Levente Uzonyi <leves at caesar.elte.hu>:

Hi Christoph,

I still feel like using #ifNil:, #ifNotNil: in a cascade is not right.
In this case, having #yourself inside the #ifNotNil: block looks more
natural to me:

^(self browseVersionsOf: aCompiledMethod) ifNotNil: [:browser |
browser
selectMethod: aCompiledMethod;
yourself ]


Levente

On Mon, 24 Feb 2020, commits at source.squeak.org wrote:

> Christoph Thiede uploaded a new version of Tools to project The Inbox:
> http://source.squeak.org/inbox/Tools-ct.945.mcz
>
> ==================== Summary ====================
>
> Name: Tools-ct.945
> Author: ct
> Time: 24 February 2020, 1:56:51.392323 pm
> UUID: cc577466-ca48-484b-9454-11ae7ffde0b2
> Ancestors: Tools-mt.940
>
> Fixes a bug/unnecessary limitation in VersionsBrowser class >> #browseMethod: that raised an error when browsing a method that had been removed from the system.
>
> You can also reproduce it via: thisContext method browse "on a fresh image".
>
> This commit replaces Tools-ct.944, which has been refactored again to reuse the return carat according to Kent Beck ("Format conditionals so their value is used where it clearly expresses the intent of the method"). Thanks to Chris for the reminder!
>
> =============== Diff against Tools-mt.940 ===============
>
> Item was changed:
> ----- Method: VersionsBrowser class>>browseMethod: (in category 'instance creation') -----
> browseMethod: aCompiledMethod
>
> + ^ (self browseVersionsOf: aCompiledMethod)
> + ifNotNil: [:browser |
> + browser selectMethod: aCompiledMethod];
> - ^ (self browseVersionsForClass: aCompiledMethod methodClass selector: aCompiledMethod selector)
> - selectMethod: aCompiledMethod;
> yourself!
>
> Item was added:
> + ----- Method: VersionsBrowser class>>browseVersionsOf: (in category 'instance creation') -----
> + browseVersionsOf: aCompiledMethod
> +
> + | methodClass methodSelector |
> + methodClass := aCompiledMethod methodClass.
> + methodSelector := aCompiledMethod selector.
> + ^ self
> + browseVersionsOf: aCompiledMethod
> + class: methodClass
> + meta: methodClass isMeta
> + category: (methodClass organization categoryOfElement: methodSelector)
> + selector: methodSelector!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200225/cf8f4db7/attachment.html>


More information about the Squeak-dev mailing list