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]]. ].! |
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]]. > ].! > > |
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]]. >> ].! >> >> > |
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]]. >>> ].! >>> >>> >> > |
In reply to this post by commits-2
> * Use the canonical Array empty rather than #();
What's wrong with #() ? Stef |
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 > |
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 - |
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 - > > |
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 - > > |
> 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 |
Free forum by Nabble | Edit this page |