[squeak-dev] Further steps on BlockClosure controlling methods (was: The Trunk: Kernel-ct.1295.mcz)
Christoph.Thiede at student.hpi.uni-potsdam.de
Sat Mar 7 14:01:50 UTC 2020
Take this as a memo for myself -- of course, it would be great to hear your ideas about the following points!
* Implement the same return logic for #while(True|False)[:]. This might also require changes in the Compiler.
Inline #whileNil(:) implementation as well.
General question: Is there such a thing as "too much inlining"? Would it be desirable to inline #cull: and others? Where do we draw the line between performance and Smalltalk-essential explorability?
Implement all these controlling methods in a way that could work without inlining (though slow). At the moment, #whileTrue: refers to itself.
An approach that completely foregos inline code would either need to use recursion (linear complexity) or "thisContext restart" (constant time complexity).
* Should we maybe find a way to highlight methods that are inlined? For example, by using a pragma <inlined>. Or rather ask Encoder for it than storing this information in the methods.
Should we warn or forbid the user to override (or even overwrite) such methods?
* Similar concern: It is dangerous to override #class et al., should we warn here, too?
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von commits at source.squeak.org <commits at source.squeak.org>
Gesendet: Dienstag, 3. März 2020 22:38 Uhr
An: squeak-dev at lists.squeakfoundation.org; packages at lists.squeakfoundation.org
Betreff: [squeak-dev] The Trunk: Kernel-ct.1295.mcz
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
==================== Summary ====================
Time: 24 January 2020, 5:20:51.814415 pm
Extends BlockClosure >> #whileNil: by returning the final non-nil value. Adds #whileNil analogous to #whileTrue and #whileFalse.
[Project uiManager chooseFrom: #(foo bar) values: #(Foo Bar)] whileNil.
[Project uiManager chooseFrom: #(foo bar) values: #(Foo Bar)] whileNil: [self inform: 'You have to decide!']
=============== Diff against Kernel-nice.1292 ===============
Item was added:
+ ----- Method: BlockClosure>>whileNil (in category 'controlling') -----
+ "Unlike #whileTrue/False this is not compiled inline."
+ | result |
+ [(result := self value) isNil] whileTrue.
+ ^ result
Item was changed:
----- Method: BlockClosure>>whileNil: (in category 'controlling') -----
"Unlike #whileTrue/False: this is not compiled inline."
+ | result |
+ [(result := self value) isNil] whileTrue: [aBlock value].
+ ^ result
- ^ [self value isNil] whileTrue: [aBlock value]
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev