[RCR] introducing Hash-like mixin

Hi gurus and nubys,

If you ever wanted to subclass hash but it was too hard..

If you ever wanted to write Hash::Regexp, Hash::Approx and
Hash::Cannabinol in ruby, but felt that you have to implement too much
methods..

in general if you ever used YourClass#[]=(key,val)..

go vote for this rcr :slight_smile:

Ok, stop cheerleading, the rcr is here:
http://rcrchive.net/rcr/RCR/RCR261

A better name than Hashable (inexact) and Map (misses the -able
prefix) would be much appreciated.

Indexable?

martin

路路路

gabriele renzi <surrender_it@remove.yahoo.it> wrote:

A better name than Hashable (inexact) and Map (misses the -able
prefix) would be much appreciated.

HashEnabled?

-a

路路路

On Thu, 17 Jun 2004, gabriele renzi wrote:

Hi gurus and nubys,

If you ever wanted to subclass hash but it was too hard..

If you ever wanted to write Hash::Regexp, Hash::Approx and
Hash::Cannabinol in ruby, but felt that you have to implement too much
methods..

in general if you ever used YourClass#=(key,val)..

go vote for this rcr :slight_smile:

Ok, stop cheerleading, the rcr is here:
RCR::RCR261 - RCRchive home

A better name than Hashable (inexact) and Map (misses the -able
prefix) would be much appreciated.

--

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
A flower falls, even though we love it; and a weed grows, even though we do
not love it. --Dogen

===============================================================================

Array.

-a

路路路

On Thu, 17 Jun 2004, Martin DeMello wrote:

gabriele renzi <surrender_it@remove.yahoo.it> wrote:

A better name than Hashable (inexact) and Map (misses the -able
prefix) would be much appreciated.

Indexable?

martin

--

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
A flower falls, even though we love it; and a weed grows, even though we do
not love it. --Dogen

===============================================================================

the point is that a Map(temporary name) object can look like ruby's
Hashes, but have a much different implementation (say, some kind of
tree), and hashing defines a specific behaviour. Dictionary may be
another one, but still ugly to me.

路路路

il Thu, 17 Jun 2004 06:27:25 -0600, "Ara.T.Howard" <ahoward@noaa.gov> ha scritto::

HashEnabled?

Map or Dictionary are the only real choices, AFAIC. I really like Map
as a name here.

Gavin

路路路

On Thursday, June 17, 2004, 11:03:28 PM, gabriele wrote:

il Thu, 17 Jun 2004 06:27:25 -0600, "Ara.T.Howard" <ahoward@noaa.gov> > ha scritto::

HashEnabled?

the point is that a Map(temporary name) object can look like ruby's
Hashes, but have a much different implementation (say, some kind of
tree), and hashing defines a specific behaviour. Dictionary may be
another one, but still ugly to me.

well, what are the 'requirements'? O(1) lookup, insertion and deletion? key
-> value lookup? etc. if it's mapping keys to values, then that could be
called mapping or hashing i suppose. what about something involving 'key' and
'value'? or something using indexable with a refinement for things indexable
by number, or by any object? map may be the best work to describe this
behaviour...

-a

路路路

On Thu, 17 Jun 2004, gabriele renzi wrote:

il Thu, 17 Jun 2004 06:27:25 -0600, "Ara.T.Howard" <ahoward@noaa.gov> > ha scritto::

HashEnabled?

the point is that a Map(temporary name) object can look like ruby's
Hashes, but have a much different implementation (say, some kind of
tree), and hashing defines a specific behaviour. Dictionary may be
another one, but still ugly to me.

--

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
A flower falls, even though we love it; and a weed grows, even though we do
not love it. --Dogen

===============================================================================

>
>HashEnabled?

the point is that a Map(temporary name) object can look like ruby's
Hashes, but have a much different implementation (say, some kind of
tree), and hashing defines a specific behaviour. Dictionary may be
another one, but still ugly to me.

PairAssociative?

Borrowed from my C++ STL book[1], which lists hash_map<> as a
model of Pair Associative Container (as well as a model of
Hashed Associative Container and Unique Associative Container).

Regards,

Bill

[1] Generic Programming and the STL, Austern, Matthew H.

路路路

From: "gabriele renzi" <surrender_it@rc1.vip.ukl.yahoo.com>

il Thu, 17 Jun 2004 06:27:25 -0600, "Ara.T.Howard" <ahoward@noaa.gov> > ha scritto::

Instead of the suffix -able (as in Enumerable), a -Mixin suffix is another
choice, e.g. MapMixin or HashMixin.

Regards,

  Michael

路路路

On Thu, Jun 17, 2004 at 10:42:06PM +0900, Gavin Sinclair wrote:

On Thursday, June 17, 2004, 11:03:28 PM, gabriele wrote:

> il Thu, 17 Jun 2004 06:27:25 -0600, "Ara.T.Howard" <ahoward@noaa.gov> > > ha scritto::

>>
>>HashEnabled?

> the point is that a Map(temporary name) object can look like ruby's
> Hashes, but have a much different implementation (say, some kind of
> tree), and hashing defines a specific behaviour. Dictionary may be
> another one, but still ugly to me.

Map or Dictionary are the only real choices, AFAIC. I really like Map
as a name here.

PairAssociable? Associable? :slight_smile:

cheers,
Mark

路路路

On Jun 17, 2004, at 11:36 AM, Bill Kelly wrote:

From: "gabriele renzi" <surrender_it@rc1.vip.ukl.yahoo.com>

il Thu, 17 Jun 2004 06:27:25 -0600, "Ara.T.Howard" <ahoward@noaa.gov> >> ha scritto::

HashEnabled?

the point is that a Map(temporary name) object can look like ruby's
Hashes, but have a much different implementation (say, some kind of
tree), and hashing defines a specific behaviour. Dictionary may be
another one, but still ugly to me.

PairAssociative?

Borrowed from my C++ STL book[1], which lists hash_map<> as a
model of Pair Associative Container (as well as a model of
Hashed Associative Container and Unique Associative Container).

"Ara.T.Howard" <ahoward@noaa.gov> wrote in message news:<Pine.LNX.4.60.0406170934300.31212@harp.ngdc.noaa.gov>...

well, what are the 'requirements'? O(1) lookup, insertion and deletion? key
-> value lookup? etc. if it's mapping keys to values, then that could be
called mapping or hashing i suppose.

from the rcr: "provide a mixin for key->value mappings"
Sorry for not have stated this more clearly, but this mixin, in my
'vision', would be going to work with any kind key->value mappers, say
dbm/sdbm/gdbm/pstore/rbtree, and even stuff like Dict servers, LDAP
directories, or wikipedia.

The point that classes may be using some kind of hashing internally is
just an implementation detail. But, as I said, it's my fault to have
written such a misleading title. It was hard to fill all that blank
fields in the rcr page.

what about something involving 'key' and
'value'? or something using indexable with a refinement for things indexable
by number, or by any object? map may be the best work to describe this
behaviour...

Interesting, I like the idea of micro interfaces/mixin and fine
grained refinements, but it's up to matz to decide.
<plug>
And, btw, if somebody like this, please take two minutes to vote at
rcrchive.net
</plug>

Boost (a collection of C++ template libraries) works with tupels
rather than with pairs.

In Smalltalk there is a Collection class named KeyedCollection but
Array is an ArrayedCollection, the latter a subclass of
SequenceableCollection. Dictionary is a Subclass of Set.
IdentityDictionary is not a subclass of Dictionary. I don't want to
discuss Smalltalk's single inheritance. I just want to point out that
there are a lot of koncepts to take into account.

- fixed order (sorted keys) vs.
  variable order (may change sort function) vs.
  no order (hashed keys)
- fixed type keys vs.
  arbitrary but constant type vs.
  mixable types
- access by keys in constant time?
- allow dublicated values?
- how to cope with equal but not identical keys?
- fixed size or growable?

This list is not complete, I just did some brainstorming.

I think an appropriate name will come up when decision about the
interface is complete.

Cheers
Sascha

路路路

"Bill Kelly" <billk@cts.com> wrote:

Borrowed from my C++ STL book[1], which lists hash_map<> as a
model of Pair Associative Container (as well as a model of
Hashed Associative Container and Unique Associative Container).

Mark Hubbart <discord@mac.com> writes:

PairAssociable? Associable? :slight_smile:

Hmm, it sounds odd to me, but it has the right definition:

  associable
       adj : capable of being associated; "words associable with
             politics"

I guess I don't hear "associable" too often...

路路路

--
Josh Huber

Michael Neumann wrote:

路路路

On Thu, Jun 17, 2004 at 10:42:06PM +0900, Gavin Sinclair wrote:

On Thursday, June 17, 2004, 11:03:28 PM, gabriele wrote:

il Thu, 17 Jun 2004 06:27:25 -0600, "Ara.T.Howard" <ahoward@noaa.gov> >>>ha scritto::

HashEnabled?

the point is that a Map(temporary name) object can look like ruby's
Hashes, but have a much different implementation (say, some kind of
tree), and hashing defines a specific behaviour. Dictionary may be
another one, but still ugly to me.

Map or Dictionary are the only real choices, AFAIC. I really like Map
as a name here.

Instead of the suffix -able (as in Enumerable), a -Mixin suffix is another
choice, e.g. MapMixin or HashMixin.

Or MapMethods and/or HashMethods.

It reads nicely ...

    class Dictionary
      include MapMethods
      ....
    end

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

"Josh Huber" <huber+rt@alum.wpi.edu> wrote in message
news:877ju6kkfs.fsf@amalthea.paradoxical.net...

Mark Hubbart <discord@mac.com> writes:

> PairAssociable? Associable? :slight_smile:

Hmm, it sounds odd to me, but it has the right definition:

  associable
       adj : capable of being associated; "words associable with
             politics"

I guess I don't hear "associable" too often...

--
Josh Huber

No, it's not right - the container itself is an associator; it associates
its key/value pairs, which are associable.

I recommend Associative

s = FooBar.new
t = Quux.new

h = {}
h[s] = t

s and t are now associated with other. Are s and t Associable?

Gavin

路路路

On Friday, June 18, 2004, 6:18:19 AM, Josh wrote:

Mark Hubbart <discord@mac.com> writes:

PairAssociable? Associable? :slight_smile:

Hmm, it sounds odd to me, but it has the right definition:

  associable
       adj : capable of being associated; "words associable with
             politics"

I guess I don't hear "associable" too often...

Yes, I like it. That sound much more natural and tells what's actually
doing (including methods related to mapping).

Regards,

  Michael

路路路

On Fri, Jun 18, 2004 at 07:01:59AM +0900, Jim Weirich wrote:

Michael Neumann wrote:
>On Thu, Jun 17, 2004 at 10:42:06PM +0900, Gavin Sinclair wrote:
>
>>On Thursday, June 17, 2004, 11:03:28 PM, gabriele wrote:
>>
>>
>>>il Thu, 17 Jun 2004 06:27:25 -0600, "Ara.T.Howard" <ahoward@noaa.gov> > >>>ha scritto::
>>
>>>>HashEnabled?
>>
>>>the point is that a Map(temporary name) object can look like ruby's
>>>Hashes, but have a much different implementation (say, some kind of
>>>tree), and hashing defines a specific behaviour. Dictionary may be
>>>another one, but still ugly to me.
>>
>>Map or Dictionary are the only real choices, AFAIC. I really like Map
>>as a name here.
>
>
>Instead of the suffix -able (as in Enumerable), a -Mixin suffix is another
>choice, e.g. MapMixin or HashMixin.

Or MapMethods and/or HashMethods.

It reads nicely ...

   class Dictionary
     include MapMethods
     ....
   end