The Inbox: Kernel-fbs.695.mcz

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

The Inbox: Kernel-fbs.695.mcz

commits-2
A new version of Kernel was added to project The Inbox:
http://source.squeak.org/inbox/Kernel-fbs.695.mcz

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

Name: Kernel-fbs.695
Author: fbs
Time: 7 June 2012, 9:05:22.987 pm
UUID: 0b1b9159-c4b6-4c3b-934c-c19d87b758b2
Ancestors: Kernel-nice.693

* Use the canonical Array empty rather than #();
* the instvar's initialised to an Array anyway so #ifNotNil: is a no-op.

=============== Diff against Kernel-nice.693 ===============

Item was changed:
  ----- Method: Promise>>initialize (in category 'initialize') -----
  initialize
  isResolved := false.
+ resolvers := Array empty.
- resolvers := #().
  mutex := Mutex new.!

Item was changed:
  ----- Method: Promise>>resolveWith: (in category 'resolving') -----
  resolveWith: arg
  "Resolve this promise"
  mutex critical: [
  isResolved ifTrue: [self error: 'Promise was already resolved'].
  value := arg.
  isResolved := true.
+ resolvers do: [:r | self evaluateResolver: r].
- resolvers ifNotNil: [resolvers do: [:r | self evaluateResolver: r]].
  ].!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-fbs.695.mcz

Nicolas Cellier
You could also change
evaluateResolver: resolverBlock
        resolverBlock cull: value

Nicolas
       

2012/6/7  <[hidden email]>:

> A new version of Kernel was added to project The Inbox:
> http://source.squeak.org/inbox/Kernel-fbs.695.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-fbs.695
> Author: fbs
> Time: 7 June 2012, 9:05:22.987 pm
> UUID: 0b1b9159-c4b6-4c3b-934c-c19d87b758b2
> Ancestors: Kernel-nice.693
>
> * Use the canonical Array empty rather than #();
> * the instvar's initialised to an Array anyway so #ifNotNil: is a no-op.
>
> =============== Diff against Kernel-nice.693 ===============
>
> Item was changed:
>  ----- Method: Promise>>initialize (in category 'initialize') -----
>  initialize
>        isResolved := false.
> +       resolvers := Array empty.
> -       resolvers := #().
>        mutex := Mutex new.!
>
> Item was changed:
>  ----- Method: Promise>>resolveWith: (in category 'resolving') -----
>  resolveWith: arg
>        "Resolve this promise"
>        mutex critical: [
>                isResolved ifTrue: [self error: 'Promise was already resolved'].
>                value := arg.
>                isResolved := true.
> +               resolvers do: [:r | self evaluateResolver: r].
> -               resolvers ifNotNil: [resolvers do: [:r | self evaluateResolver: r]].
>        ].!
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-fbs.695.mcz

Frank Shearar-3
As you wish!

I've deliberately kept the parents of these commits as the latest
trunk version, so it's easier to see what's going on. That works, at
least, for these tiny guys.

frank

On 7 June 2012 21:15, Nicolas Cellier
<[hidden email]> wrote:

> You could also change
> evaluateResolver: resolverBlock
>        resolverBlock cull: value
>
> Nicolas
>
>
> 2012/6/7  <[hidden email]>:
>> A new version of Kernel was added to project The Inbox:
>> http://source.squeak.org/inbox/Kernel-fbs.695.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Kernel-fbs.695
>> Author: fbs
>> Time: 7 June 2012, 9:05:22.987 pm
>> UUID: 0b1b9159-c4b6-4c3b-934c-c19d87b758b2
>> Ancestors: Kernel-nice.693
>>
>> * Use the canonical Array empty rather than #();
>> * the instvar's initialised to an Array anyway so #ifNotNil: is a no-op.
>>
>> =============== Diff against Kernel-nice.693 ===============
>>
>> Item was changed:
>>  ----- Method: Promise>>initialize (in category 'initialize') -----
>>  initialize
>>        isResolved := false.
>> +       resolvers := Array empty.
>> -       resolvers := #().
>>        mutex := Mutex new.!
>>
>> Item was changed:
>>  ----- Method: Promise>>resolveWith: (in category 'resolving') -----
>>  resolveWith: arg
>>        "Resolve this promise"
>>        mutex critical: [
>>                isResolved ifTrue: [self error: 'Promise was already resolved'].
>>                value := arg.
>>                isResolved := true.
>> +               resolvers do: [:r | self evaluateResolver: r].
>> -               resolvers ifNotNil: [resolvers do: [:r | self evaluateResolver: r]].
>>        ].!
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-fbs.695.mcz

Nicolas Cellier
I think the server shows the diff versus latest ancestor present in
trunk, so this discipline is not strictly necessary...
Though it also reduces ancestor meta-data weight which cannot be bad.

Nicolas

2012/6/7 Frank Shearar <[hidden email]>:

> As you wish!
>
> I've deliberately kept the parents of these commits as the latest
> trunk version, so it's easier to see what's going on. That works, at
> least, for these tiny guys.
>
> frank
>
> On 7 June 2012 21:15, Nicolas Cellier
> <[hidden email]> wrote:
>> You could also change
>> evaluateResolver: resolverBlock
>>        resolverBlock cull: value
>>
>> Nicolas
>>
>>
>> 2012/6/7  <[hidden email]>:
>>> A new version of Kernel was added to project The Inbox:
>>> http://source.squeak.org/inbox/Kernel-fbs.695.mcz
>>>
>>> ==================== Summary ====================
>>>
>>> Name: Kernel-fbs.695
>>> Author: fbs
>>> Time: 7 June 2012, 9:05:22.987 pm
>>> UUID: 0b1b9159-c4b6-4c3b-934c-c19d87b758b2
>>> Ancestors: Kernel-nice.693
>>>
>>> * Use the canonical Array empty rather than #();
>>> * the instvar's initialised to an Array anyway so #ifNotNil: is a no-op.
>>>
>>> =============== Diff against Kernel-nice.693 ===============
>>>
>>> Item was changed:
>>>  ----- Method: Promise>>initialize (in category 'initialize') -----
>>>  initialize
>>>        isResolved := false.
>>> +       resolvers := Array empty.
>>> -       resolvers := #().
>>>        mutex := Mutex new.!
>>>
>>> Item was changed:
>>>  ----- Method: Promise>>resolveWith: (in category 'resolving') -----
>>>  resolveWith: arg
>>>        "Resolve this promise"
>>>        mutex critical: [
>>>                isResolved ifTrue: [self error: 'Promise was already resolved'].
>>>                value := arg.
>>>                isResolved := true.
>>> +               resolvers do: [:r | self evaluateResolver: r].
>>> -               resolvers ifNotNil: [resolvers do: [:r | self evaluateResolver: r]].
>>>        ].!
>>>
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-fbs.695.mcz

Stéphane Rollandin
In reply to this post by commits-2
> * Use the canonical Array empty rather than #();

What's wrong with #() ?

Stef

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-fbs.695.mcz

Frank Shearar-3
On 8 June 2012 08:57, Stéphane Rollandin <[hidden email]> wrote:
>> * Use the canonical Array empty rather than #();
>
>
> What's wrong with #() ?

Nothing hugely. I made the change because I remembered Chris Muller's
earlier statement about using a canonical instance. I like canonical
instances.

> Stef
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-fbs.695.mcz

Bert Freudenberg

On 08.06.2012, at 13:00, Frank Shearar <[hidden email]> wrote:

> On 8 June 2012 08:57, Stéphane Rollandin <[hidden email]> wrote:
>>> * Use the canonical Array empty rather than #();
>>
>>
>> What's wrong with #() ?
>
> Nothing hugely. I made the change because I remembered Chris Muller's
> earlier statement about using a canonical instance. I like canonical
> instances.

If we think a canonical instance is preferable, then we should change the compiler. IMHO, "Array new" adds unnecessary clutter over "#()".

FWIW, I'd call #() canonical, whereas "Array empty" is decidedly not part of the Smalltalk canon.

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-fbs.695.mcz

Frank Shearar-3
On 8 June 2012 12:42, Bert Freudenberg <[hidden email]> wrote:

>
> On 08.06.2012, at 13:00, Frank Shearar <[hidden email]> wrote:
>
>> On 8 June 2012 08:57, Stéphane Rollandin <[hidden email]> wrote:
>>>> * Use the canonical Array empty rather than #();
>>>
>>>
>>> What's wrong with #() ?
>>
>> Nothing hugely. I made the change because I remembered Chris Muller's
>> earlier statement about using a canonical instance. I like canonical
>> instances.
>
> If we think a canonical instance is preferable, then we should change the compiler. IMHO, "Array new" adds unnecessary clutter over "#()".
>
> FWIW, I'd call #() canonical, whereas "Array empty" is decidedly not part of the Smalltalk canon.

If it's an issue, I'll just resubmit with #(). It's not worth arguing about.

I had _assumed_ that #() was not canonical (because I could see not
reason for it to _necessarily_ be canonical, and Chris Muller's
comment on "Array empty", but if the Compiler does enforce that then
I'd be happy with #(). It's nicely visual. Certainly "#() == #()" is
true, but I didn't assume that two methods that each use #() would use
the same instance:

Object subclass Foo.
Foo >> #foo
  ^ #()

Foo >> #bar
  ^ #()

Foo new == Foo new bar "=> "false"

So... I guess Compiler doesn't use a canonical empty array, and maybe
it should. At any rate, that's well outside this commit's scope.

frank

> - Bert -
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-fbs.695.mcz

Chris Muller-3
In reply to this post by Bert Freudenberg
> FWIW, I'd call #() canonical, whereas "Array empty" is decidedly not part of the Smalltalk
> canon.

Well, there are already six #empty constructors in the image,
"decided" by four prominent authors dating back to 2004.  And that's
just the implementors, there are many more authors who decided to SEND
the #empty message even though they didn't need to.

I don't see how type-specific symbology could be less "cluttered" than
a couple of English words, but I don't want argue about taste.  More
important is the developing consistency among of class-side API's -- I
have #empty in some in my own apps and the six in the image proves
there are a variety of different kinds of objects that make sense to
have an "empty" instance.  A consistent API also provides polymorphic
opportunities.

I see nothing wrong #empty in fact I think its more
intention-revealing, consistent and opportunistic.





On Fri, Jun 8, 2012 at 6:42 AM, Bert Freudenberg <[hidden email]> wrote:

>
> On 08.06.2012, at 13:00, Frank Shearar <[hidden email]> wrote:
>
>> On 8 June 2012 08:57, Stéphane Rollandin <[hidden email]> wrote:
>>>> * Use the canonical Array empty rather than #();
>>>
>>>
>>> What's wrong with #() ?
>>
>> Nothing hugely. I made the change because I remembered Chris Muller's
>> earlier statement about using a canonical instance. I like canonical
>> instances.
>
> If we think a canonical instance is preferable, then we should change the compiler. IMHO, "Array new" adds unnecessary clutter over "#()".
>
>
> - Bert -
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-fbs.695.mcz

Stéphane Rollandin
> I see nothing wrong #empty in fact I think its more
> intention-revealing, consistent and opportunistic.

I have nothing against Array empty, it just seems weird to me to go hunt
down appearances of #() and change them. Live and let live.

Stef