Hi all,
recently I stumbled upon an extension method for Dictionary which *might* fit well into the Trunk:
Dictionary >> #at: key ifAbsentPut: startBlock ifPresentPut: nextBlock
"(c) 2020 Basti Kruck und Marcel Taeumel. :-)" (self includesKey: key) ifFalse: [
^ self at: key put: startBlock value]. ^ self
at: key
put: (nextBlock value: (self at: key))
See https://github.com/hpi-swa/vivide/blob/c4ac5ea562bd563358d52ee41c149a3fbcff….
Usage:
counter := counters at: key ifAbsentPut: [0] ifPresentPut: [:i | i + 1]
What do you think, should we copy this into the Trunk? Or is it just fine to do something like this instead at the sender side:
counter := counters at: key put: (counters at: key ifAbsent: [0] ifPresent: [:i | i + 1])
<http://www.hpi.de/>
Also, I'm not sure about the order of arguments.
Best,
Christoph
Marcel Taeumel uploaded a new version of FFI-Kernel to project FFI:
http://source.squeak.org/FFI/FFI-Kernel-mt.122.mcz
==================== Summary ====================
Name: FFI-Kernel-mt.122
Author: mt
Time: 1 May 2021, 8:25:28.22519 am
UUID: 6c3424fd-34f9-f44e-b109-3e27c0690885
Ancestors: FFI-Kernel-mt.121
Adds check to separate integer types from float types. There already is #isIntegerType. For example, callback handles can use this to choose between integer-registers and float-registers easily based on argument types.
=============== Diff against FFI-Kernel-mt.121 ===============
Item was added:
+ ----- Method: ExternalStructureType>>isFloatType (in category 'testing') -----
+ isFloatType
+ "Overwritten to not raise an error for struct types."
+
+ ^ false!
Item was added:
+ ----- Method: ExternalType>>isFloatType (in category 'testing') -----
+ isFloatType
+ "Return true if the receiver is a built-in float type"
+ | type |
+ type := self atomicType.
+ ^type = FFITypeSingleFloat or: [type = FFITypeDoubleFloat]!