The Trunk: Kernel-nice.1307.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Kernel-nice.1307.mcz

commits-2
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.1307.mcz

==================== Summary ====================

Name: Kernel-nice.1307
Author: nice
Time: 3 March 2020, 11:04:29.913092 pm
UUID: 6c5ee38a-4234-49e4-ba8c-232f6c21167d
Ancestors: Kernel-mt.1306, Kernel-ct.1295, Kernel-nice.1295, Kernel-ct.1299, Kernel-ct.1300

Merge Kernel-mt.1306, Kernel-ct.1295, Kernel-nice.1295, Kernel-ct.1299, Kernel-ct.1300

Kernel-ct.1295:
        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!']

Kernel-nice.1295:
        Fast-up isAnExactFloat.
Correct a typo in a comment.

Kernel-ct.1299:
        Refactor #valueSupplyingAnswers::

- Don't reinvent the wheel of Exception >> #pass
- Use #ifError:

See also http://forum.world.st/The-Trunk-Kernel-mt-1283-mcz-td5107403.html.

Kernel-ct.1300:
        Fix multiple typos in BlockClosure and FullBlockClosure documentation

=============== Diff against Kernel-mt.1306 ===============

Item was changed:
  ----- Method: BlockClosure>>reentrant (in category 'private') -----
  reentrant
  "Answer a version of the recever that can be reentered.
+ Closures are reentrant (unlike BlockContext), so simply answer self."
- Closures are reentrant (unlike BlockContect) so simply answer self."
  ^self!

Item was changed:
  ----- Method: BlockClosure>>valueSupplyingAnswers: (in category 'evaluating') -----
  valueSupplyingAnswers: aListOfPairs
+ "Evaluate the receiver using a list of questions / answers that might be called upon to automatically respond to Object>>confirm: or FillInTheBlank requests"
- "evaluate the block using a list of questions / answers that might be called upon to
- automatically respond to Object>>confirm: or FillInTheBlank requests"
 
+ ^ self on: ProvideAnswerNotification do: [ :notification |
+ | caption |
+ caption := notification messageText withSeparatorsCompacted. "to remove new lines"
+ aListOfPairs
+ detect: [ :each |
+ caption = each first
+ or: [ (caption includesSubstring: each first caseSensitive: false)
+ or: [ (each first match: caption)
+ or: [ (caption respondsTo: #matchesRegex:)
+ and: [ [caption matchesRegex: each first] ifError: [false] ] ] ] ] ]
+ ifFound: [ :answer | notification resume: answer second ]
+ ifNone: [ notification pass ] ]!
- ^self
- on: ProvideAnswerNotification
- do: [ :notification |
- | caption |
- caption := notification messageText withSeparatorsCompacted. "to remove new lines"
- aListOfPairs
- detect:  [ :each |
- caption = each first
- or: [ (caption includesSubstring: each first caseSensitive: false)
- or: [ (each first match: caption)
- or: [ (caption respondsTo: #matchesRegex:)
- and: [ [caption matchesRegex: each first] on: Error do: [false] ] ] ] ] ]
- ifFound: [ :answer | notification resume: answer second ]
- ifNone: [
- (ProvideAnswerNotification signal: notification messageText)
- ifNil: [ notification resume ]
- ifNotNil: [ :outerAnswer | notification resume: outerAnswer ] ] ]!

Item was added:
+ ----- Method: BlockClosure>>whileNil (in category 'controlling') -----
+ whileNil
+ "Unlike #whileTrue/False this is not compiled inline."
+ | result |
+ [(result := self value) isNil] whileTrue.
+ ^ result
+ !

Item was changed:
  ----- Method: BlockClosure>>whileNil: (in category 'controlling') -----
  whileNil: aBlock
  "Unlike #whileTrue/False: this is not compiled inline."
+ | result |
+ [(result := self value) isNil] whileTrue: [aBlock value].
+ ^ result
- ^ [self value isNil] whileTrue: [aBlock value]
  !

Item was changed:
  BlockClosure variableSubclass: #FullBlockClosure
  instanceVariableNames: 'receiver'
  classVariableNames: ''
  poolDictionaries: ''
  category: 'Kernel-Methods'!
 
+ !FullBlockClosure commentStamp: 'ct 2/14/2020 15:56' prior: 0!
+ Instances of FullBlockClosure represent blocks, a sequence of statements inside square brackets that can be evaluated at any time via one of the value messages (value, value:, value:value:, ..., valueWithArguments:), which answer their last statement.  Blocks therefore allow deferred evaluation and so are used to build control structures where a sequence of statements are evaluated or not depending on other values in the program.
- !FullBlockClosure commentStamp: 'eem 4/10/2017 11:18' prior: 0!
- Instances of FullBlockClosure represent blocks, a sequence of statements inside square brackets that can be evaluated at any time via one of the value messages (value, value:, value:value:, ... valueWithArguments:), which answer their last statement.  Blocks therefore allow deferred evaluation and so are used to buikld control structures where a sequence of statements are evaluated or not depending on other values in the program.
 
  FullBlockClosure is a refinement of BlockClosure that allows the block to use its own method to hold its code instead of embedding that code within its home method.
 
+ Implementation notes:
- Implementation:
 
  A FullBlockClosure is a closure that can be independent of any outerContext if desired.  It has its own method (currently reusing the startpc inst var) and its own receiver.  outerContext can be either a Context or nil.
 
+ This closure design, implemented by Eliot Miranda and Clement Bera along with the sista work, aims to simplify the block closure model while enhacing its capabilities. It allows lazy decompilation of closures and fast machine code dispatch in Cog's JIT, while allowing inlining of methods and blocks to be independent from their enclosing blocks.
- This closure design, implemented by Eliot Miranda and Clement Bera along with the sista work aims to simplify the block closure model while enhacing its capabilities. It allows lazy decompilation of closures and fast machine code dispatch in Cog's JIT, while allowing inlining of methods and blocks to be independent from their enclosing blocks.
 
  At closure creation time, the bytecode specifies:
  - the compiledBlock to execute when executing this block's code (in the literal frame)
  - if the receiver is the current receiver or a receiver passed on stack before the copied values.
  - if the closure needs an outerContext. outerContexts are used for non local returns and debugging. Blocks with non local returns have to set their outerContext. For other blocks (97% of blocks), it's a trade-off between performance and debuggability.
 
  Instance Variables (inherited)
  numArgs <SmallInteger>
  outerContext: <Context|nil>
  compiledBlock(startpc) <CompiledBlock>
 
  Instance Variables
  receiver: <Object>
 
  numArgs
  - the number of arguments the block expects. This is superfluous; the number of arguments can be obtained from the receiver's compiledBlock.
 
  outerContext
  - the Context of the method or block activation in which the receiver is created.
 
  compiledBlock(startpc)
  - reused to refer to the CompiledBlock that implements the receiver's code.
 
  receiver
  - the receiver of the message that created the block's home method activation.!

Item was changed:
  ----- Method: Integer>>isAnExactFloat (in category 'testing') -----
  isAnExactFloat
  "Answer true if this Integer can be converted exactly to a Float"
  | h |
  (h := self highBitOfMagnitude) <= Float precision
  ifTrue: [^ true].
  ^ h - 1 <= Float emax
+ and: [(self anyBitOfMagnitudeFrom: 1 to: h - Float precision) not]!
- and: [h - self abs lowBit < Float precision]!

Item was changed:
  ----- Method: NumberParser>>makeFloatFromMantissa:exponent:base: (in category 'parsing-private') -----
  makeFloatFromMantissa: m exponent: k base: aRadix
+ "Convert infinite precision arithmetic into limited precision Floating point.
+ This algorithm rely on correct IEEE rounding mode
- "Convert infinite precision arithmetic into Floating point.
- This alogrithm rely on correct IEEE rounding mode
  being implemented in Integer>>asFloat and Fraction>>asFloat"
 
  k = 0 ifTrue: [ ^m asFloat ].
  k > 0 ifTrue: [ ^(m * (aRadix raisedToInteger: k)) asFloat ].
  ^(Fraction numerator: m denominator: (aRadix raisedToInteger: k negated)) asFloat!