WeakSet>>#includes: and Deprecation

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

WeakSet>>#includes: and Deprecation

S11001001
I was looking at all the #doWithIndex:-like methods and decided a
deprecation tag might be good, at least for my own code.  I'm not even
sure I'm going to use it in my own code, but it gave me a chance to
break WeakSet, so

[hidden email]--2007-nocandy/smalltalk--backstage--2.2--patch-30
    support #includes: on WeakSets

against upstream patch-393, attached as weakset-includes.diff.

Based on a search for findIndex in HashedCollection, I don't think any
other methods are affected.

Also attached is Deprecation.st.  Its Commentary section explains its
use.  The biggest benefit is being able to write "self deprecate: 'I am
poorly written'" and such in your code. :)

I'm happy to change the license if you want to include it in gst.

--
;;; Stephen Compall ** http://scompall.nocandysw.com/blog **
"Peta" is Greek for fifth; a petabyte is 10 to the fifth power, as
well as fifth in line after kilo, mega, giga, and tera.
  -- Lee Gomes, performing every Wednesday in his tech column
     "Portals" on page B1 of The Wall Street Journal

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

weakset-includes.diff (1K) Download Attachment
Deprecation.st (3K) Download Attachment
signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: WeakSet>>#includes: and Deprecation

Paolo Bonzini-2

> [hidden email]--2007-nocandy/smalltalk--backstage--2.2--patch-30
>     support #includes: on WeakSets
>
> against upstream patch-393, attached as weakset-includes.diff.

I don't especially like the patch, but given the current implementation
of WeakSets it's probably the best idea.  An alternative would be to
reimplement #findIndex: and #add: as in Dictionary (and add a few other
affected methods, like #rehashObjectsAfter:).  For now I'll keep yours.

> smalltalk--backstage--2.2--patch-31
> smalltalk--backstage--2.2--patch-32

Applied.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

[patch] WeakSet>>#includes: without unneeded HomedAssociations

S11001001
On Mon, 2007-06-11 at 13:39 +0200, Paolo Bonzini wrote:
> I don't especially like the patch, but given the current implementation
> of WeakSets it's probably the best idea.  An alternative would be to
> reimplement #findIndex: and #add: as in Dictionary (and add a few other
> affected methods, like #rehashObjectsAfter:).  For now I'll keep yours.

Specifically, added #addWhileGrowing:, #shallowCopy, and #deepCopy as
well.

smalltalk--backstage--2.2--patch-34 against patch-395 (also attached)

--
;;; Stephen Compall ** http://scompall.nocandysw.com/blog **
"Peta" is Greek for fifth; a petabyte is 10 to the fifth power, as
well as fifth in line after kilo, mega, giga, and tera.
  -- Lee Gomes, performing every Wednesday in his tech column
     "Portals" on page B1 of The Wall Street Journal

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

weakset-2.diff (6K) Download Attachment
signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [patch] WeakSet>>#includes: without unneeded HomedAssociations

Paolo Bonzini
Stephen Compall wrote:

> On Mon, 2007-06-11 at 13:39 +0200, Paolo Bonzini wrote:
>> I don't especially like the patch, but given the current implementation
>> of WeakSets it's probably the best idea.  An alternative would be to
>> reimplement #findIndex: and #add: as in Dictionary (and add a few other
>> affected methods, like #rehashObjectsAfter:).  For now I'll keep yours.
>
> Specifically, added #addWhileGrowing:, #shallowCopy, and #deepCopy as
> well.
>
> smalltalk--backstage--2.2--patch-34 against patch-395 (also attached)

Thanks.  I also refactored the creation of HomedAssociation:

newAssociation: key
     ^HomedAssociation key: key value: nil environment: self
         makeEphemeron;
         yourself!

Now the next step would be to add

    HashedCollection >> findElementIndex: anObject [
        ^self findIndex: anObject
    ]
    Dictionary >> findElementIndex: anObject [
        ^self findIndex: anObject key
    ]
    LookupTable >> findElementIndex: anObject [
        ^self findIndex: anObject
    ]
    WeakSet >> findElementIndex: anObject [
        ^self findIndex: anObject key
    ]

This would be used to find the index corresponding to an *existing*
item, as required in #rehashObjectsAfter: and #addWhileGrowing:.

Paolo



_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk