[squeak-dev] The Inbox: Collections-mt.812.mcz

Chris Muller asqueaker at gmail.com
Tue Dec 18 21:20:07 UTC 2018


Hi Marcel,

I've needed something like this before too, but since I also wanted to
work more with the Error's, I simply provided an additional Block for
the inner-layer which took each Error as the argument.  Then my
calling could log to Transcript or add to a separate Collection (since
I prefer to view "object messages" in an Explorer instead of only text
in the Transcript), and nicely avoids the unpleasant dependency on Transcript.

I also think it could just trap Error (or MessageNotUnderstood) since
that is the stated intended usage.  I think if one needed to specify a
custom exceptionOrExceptionSet, then it seems like they'd probably
just write normal error-handling code.

Best,
  Chris






On Tue, Dec 18, 2018 at 4:58 AM <commits at source.squeak.org> wrote:
>
> A new version of Collections was added to project The Inbox:
> http://source.squeak.org/inbox/Collections-mt.812.mcz
>
> ==================== Summary ====================
>
> Name: Collections-mt.812
> Author: mt
> Time: 18 December 2018, 11:58:09.289023 am
> UUID: 64ff5a45-61b5-5642-aa46-9fbeac0215dd
> Ancestors: Collections-eem.811
>
> Adds a small scripting/debugging interface to evaluate code on a heterogeneous collection. Ignore errors on the way.
>
> 1. Example: A bunch of morphs whose n-th submorph should be made yellow. Would raise errors for morphs with less than n submorphs.
>
> ActiveWorld submorphs try: [:ea | ea submorphs fifth color: Color yellow].
>
> 2. Example: Fetch the selected classes of all code browsers through the submorph interface.
>
> | results |
> results := OrderedCollection new.
> ActiveWorld submorphs try: [:ea | results add: ea model selectedClass].
> results explore.
>
> =============== Diff against Collections-eem.811 ===============
>
> Item was added:
> + ----- Method: Collection>>try: (in category 'enumerating') -----
> + try: aBlock
> +       "Evaluate aBlock with each of the receiver's elements as the argument. On error, skip that element and continue."
> +
> +       ^ self try: aBlock ignore: Error!
>
> Item was added:
> + ----- Method: Collection>>try:ignore: (in category 'enumerating') -----
> + try: aBlock ignore: exceptionOrExceptionSet
> +       "Evaluate aBlock with each of the receiver's elements as the argument. On error, skip that element and continue."
> +
> +       ^ self
> +               try: aBlock
> +               ignore: exceptionOrExceptionSet
> +               logged: false!
>
> Item was added:
> + ----- Method: Collection>>try:ignore:logged: (in category 'enumerating') -----
> + try: aBlock ignore: exceptionOrExceptionSet logged: aBoolean
> +       "Evaluate aBlock with each of the receiver's elements as the argument. On error, skip that element and continue."
> +
> +       ^ self do: [:ea |
> +               [aBlock value: ea]
> +                       on: exceptionOrExceptionSet
> +                       do: [:err | aBoolean ifTrue: [Transcript showln: err messageText]]]!
>
>


More information about the Squeak-dev mailing list