Dictionary asSet

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

Dictionary asSet

Dan Norton
aDictionary asSet should answer a set. Instead, it answers itself (a dictionary).

I tried to create a new issue but the "Submit new issue" button was disabled.

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: Dictionary asSet

Casey Ransberger-2
I think it should probably answer a set of associations, specifically, and also have a gut feeling that doing so should be relatively cheap. But don't worry so much about what I think. Look at what the other dialects do, consult book blue, etc...

Annoying Casey behavior: can you think of an SUnit test that confirms the bug? I'm not just asking you for a test case, not necessarily, but it would be good to define expected behavior in a way that allows us later to know that it has changed inadvertently if it does.

The test is more important than the fix, if the code is to be the curriculum. 

--C

On Feb 28, 2015, at 6:45 PM, "Dan Norton" <[hidden email]> wrote:

aDictionary asSet should answer a set. Instead, it answers itself (a dictionary).

I tried to create a new issue but the "Submit new issue" button was disabled.
_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: Dictionary asSet

Nicolas Cellier


2015-03-01 10:52 GMT+01:00 Casey Ransberger <[hidden email]>:
I think it should probably answer a set of associations, specifically, and also have a gut feeling that doing so should be relatively cheap. But don't worry so much about what I think. Look at what the other dialects do, consult book blue, etc...


Please, no.
A Dictionary behaves as a Collection of values,  it's just that it has special keys for indexing its contents.
Why should asSet do something different than asArray for example?
If we want a set of associations, we can just write aDictionary associations asSet.

Nicolas

Annoying Casey behavior: can you think of an SUnit test that confirms the bug? I'm not just asking you for a test case, not necessarily, but it would be good to define expected behavior in a way that allows us later to know that it has changed inadvertently if it does.

The test is more important than the fix, if the code is to be the curriculum. 

--C

On Feb 28, 2015, at 6:45 PM, "Dan Norton" <[hidden email]> wrote:

aDictionary asSet should answer a set. Instead, it answers itself (a dictionary).

I tried to create a new issue but the "Submit new issue" button was disabled.
_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org



_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: Dictionary asSet

Dan Norton
Comments in line...
On 1 Mar 2015 at 15:06, Nicolas Cellier wrote:
> 2015-03-01 10:52 GMT+01:00 Casey Ransberger
>     I think it should probably answer a set of associations,
> specifically, and also have a gut
>     feeling that doing so should be relatively cheap. But don't
> worry so much about what I think.
>     Look at what the other dialects do, consult book blue, etc...
>
>
> Please, no.
> A Dictionary behaves as a Collection of values,  it's just that it
> has special keys for indexing its
> contents.
> Why should asSet do something different than asArray for example?
> If we want a set of associations, we can just write aDictionary
> associations asSet.
>
Someone looking at the Terse Guide sees #asOrderedCollection, #asBag, etc. answer the values of the dictionary in instances of those classes. So they might expect #asSet to follow suit.

In Cuis, Dictionary inherits from Set, unlike Squeak. Seems like Dictionary needs to have its own #asSet method.
>
>     Annoying Casey behavior: can you think of an SUnit test that
> confirms the bug? I'm not just
>     asking you for a test case, not necessarily, but it would be
> good to define expected behavior
>     in a way that allows us later to know that it has changed
> inadvertently if it does.
>
>     The test is more important than the fix, if the code is to be
> the curriculum. 
>
How about...
asSetTest
           | dx old new |
           dx _ Dictionary new
                       at: #foo put: 44; at: #bah put: 55; yourself.
           old _ dx className asSymbol.
           new _ dx asSet className asSymbol.
           self shouldnt: [old = new]
>    
>     On Feb 28, 2015, at 6:45 PM, "Dan Norton"
> <[hidden email]> wrote:
>
>     aDictionary asSet should answer a set. Instead, it answers
> itself (a dictionary).
>
>     I tried to create a new issue but the "Submit new issue" button
> was disabled.
  

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: Dictionary asSet

Juan Vuletich-4
In reply to this post by Nicolas Cellier
In Squeak, 'someDictionary asSet' answers a set with the values. It should do the same in Cuis, (like Dan and Nicolas want). Maybe we'd also adopt the idea of having HashedCollection as a superclass of both Dictionary and Set, just like in Squeak.

Any takers?

Cheers,
Juan Vuletich

On 3/1/2015 11:06 AM, Nicolas Cellier wrote:


2015-03-01 10:52 GMT+01:00 Casey Ransberger <[hidden email]>:
I think it should probably answer a set of associations, specifically, and also have a gut feeling that doing so should be relatively cheap. But don't worry so much about what I think. Look at what the other dialects do, consult book blue, etc...


Please, no.
A Dictionary behaves as a Collection of values,  it's just that it has special keys for indexing its contents.
Why should asSet do something different than asArray for example?
If we want a set of associations, we can just write aDictionary associations asSet.

Nicolas

Annoying Casey behavior: can you think of an SUnit test that confirms the bug? I'm not just asking you for a test case, not necessarily, but it would be good to define expected behavior in a way that allows us later to know that it has changed inadvertently if it does.

The test is more important than the fix, if the code is to be the curriculum. 

--C

On Feb 28, 2015, at 6:45 PM, "Dan Norton" <[hidden email]> wrote:

aDictionary asSet should answer a set. Instead, it answers itself (a dictionary).

I tried to create a new issue but the "Submit new issue" button was disabled.
_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org


_______________________________________________ Cuis mailing list [hidden email] http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org


_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: Dictionary asSet

Casey Ransberger-2
I'm pretty sure I said something like "forget what I think, look at what everyone else does." :)

Hard not to think of a dictionary as anything but a set of associations, but I'm quite sure there are perfectly practical reasons for the existing thingie.

Has anybody tried that test out? On stupid phone again...

Anyway I don't think we should worry about what we call the superclass unless it affects compat with some wanted code. Even then, a little shim in the compat package could make up for the difference, no?

--C

On Mar 1, 2015, at 11:06 AM, Juan Vuletich <[hidden email]> wrote:

In Squeak, 'someDictionary asSet' answers a set with the values. It should do the same in Cuis, (like Dan and Nicolas want). Maybe we'd also adopt the idea of having HashedCollection as a superclass of both Dictionary and Set, just like in Squeak.

Any takers?

Cheers,
Juan Vuletich

On 3/1/2015 11:06 AM, Nicolas Cellier wrote:


2015-03-01 10:52 GMT+01:00 Casey Ransberger <[hidden email]>:
I think it should probably answer a set of associations, specifically, and also have a gut feeling that doing so should be relatively cheap. But don't worry so much about what I think. Look at what the other dialects do, consult book blue, etc...


Please, no.
A Dictionary behaves as a Collection of values,  it's just that it has special keys for indexing its contents.
Why should asSet do something different than asArray for example?
If we want a set of associations, we can just write aDictionary associations asSet.

Nicolas

Annoying Casey behavior: can you think of an SUnit test that confirms the bug? I'm not just asking you for a test case, not necessarily, but it would be good to define expected behavior in a way that allows us later to know that it has changed inadvertently if it does.

The test is more important than the fix, if the code is to be the curriculum. 

--C

On Feb 28, 2015, at 6:45 PM, "Dan Norton" <[hidden email]> wrote:

aDictionary asSet should answer a set. Instead, it answers itself (a dictionary).

I tried to create a new issue but the "Submit new issue" button was disabled.
_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org


_______________________________________________ Cuis mailing list [hidden email] http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: Dictionary asSet

Dan Norton
In reply to this post by Juan Vuletich-4
On 1 Mar 2015 at 16:06, Juan Vuletich wrote:

>
> In Squeak, 'someDictionary asSet' answers a set with the values. It
> should do the same in Cuis,
> (like Dan and Nicolas want). Maybe we'd also adopt the idea of
> having HashedCollection as a
> superclass of both Dictionary and Set, just like in Squeak.
>
> Any takers?
>
> Cheers,
> Juan Vuletich
>
> On 3/1/2015 11:06 AM, Nicolas Cellier wrote:
>
>
>     2015-03-01 10:52 GMT+01:00 Casey Ransberger
>     I think it should probably answer a set of associations,
> specifically, and also have a
>     gut feeling that doing so should be relatively cheap. But don't
> worry so much about
>     what I think. Look at what the other dialects do, consult book
> blue, etc...
>
>
>     Please, no.
>     A Dictionary behaves as a Collection of values,  it's just that
> it has special keys for indexing
>     its contents.
>     Why should asSet do something different than asArray for
> example?
>     If we want a set of associations, we can just write aDictionary
> associations asSet.
>
>     Nicolas
>
>     Annoying Casey behavior: can you think of an SUnit test that
> confirms the bug? I'm
>     not just asking you for a test case, not necessarily, but it
> would be good to define
>     expected behavior in a way that allows us later to know that it
> has changed
>     inadvertently if it does.
>
>     The test is more important than the fix, if the code is to be
> the curriculum. 
>
>     --C
>    
>     On Feb 28, 2015, at 6:45 PM, "Dan Norton"
> <[hidden email]> wrote:
>
>     aDictionary asSet should answer a set. Instead, it answers
> itself (a dictionary).
>
>     I tried to create a new issue but the "Submit new issue" button
> was disabled.
>

An #asSet method for Dictionary could be implemented as:
           ^ self as: Set
which brings a question: in the spirit of Cuis, why not eliminate most of the #asXXX convenience methods, replacing them with the as: Class idiom wherever possible?

  

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: Dictionary asSet

Juan Vuletich-4
On 3/4/2015 6:45 PM, Dan Norton wrote:
On 1 Mar 2015 at 16:06, Juan Vuletich wrote:

>
> In Squeak, 'someDictionary asSet' answers a set with the values. It
> should do the same in Cuis,
> (like Dan and Nicolas want). Maybe we'd also adopt the idea of
> having HashedCollection as a
> superclass of both Dictionary and Set, just like in Squeak.
>
> Any takers?
>
> Cheers,
> Juan Vuletich
>
> On 3/1/2015 11:06 AM, Nicolas Cellier wrote:
>
>
>     2015-03-01 10:52 GMT+01:00 Casey Ransberger
>     I think it should probably answer a set of associations,
> specifically, and also have a
>     gut feeling that doing so should be relatively cheap. But don't
> worry so much about
>     what I think. Look at what the other dialects do, consult book
> blue, etc...
>
>
>     Please, no.
>     A Dictionary behaves as a Collection of values,  it's just that
> it has special keys for indexing
>     its contents.
>     Why should asSet do something different than asArray for
> example?
>     If we want a set of associations, we can just write aDictionary
> associations asSet.
>
>     Nicolas
>
>     Annoying Casey behavior: can you think of an SUnit test that
> confirms the bug? I'm
>     not just asking you for a test case, not necessarily, but it
> would be good to define
>     expected behavior in a way that allows us later to know that it
> has changed
>     inadvertently if it does.
>
>     The test is more important than the fix, if the code is to be
> the curriculum. 
>
>     --C
>    
>     On Feb 28, 2015, at 6:45 PM, "Dan Norton"
>
>     aDictionary asSet should answer a set. Instead, it answers
> itself (a dictionary).
>
>     I tried to create a new issue but the "Submit new issue" button
> was disabled.
>

An #asSet method for Dictionary could be implemented as:
           ^ self as: Set
which brings a question: in the spirit of Cuis, why not eliminate most of the #asXXX convenience methods, replacing them with the as: Class idiom wherever possible?


Yes, this is a good idea. I'm not sure if removing them, but at least making them call #as: should reduce code quite a bit.

Cheers,
Juan Vuletich

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org