Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

hashtable API #73

Closed
nyuichi opened this issue Mar 21, 2014 · 13 comments
Closed

hashtable API #73

nyuichi opened this issue Mar 21, 2014 · 13 comments

Comments

@nyuichi
Copy link
Member

nyuichi commented Mar 21, 2014

No description provided.

@stibear
Copy link
Contributor

stibear commented Jul 11, 2014

What do you think about this?

@nyuichi
Copy link
Member Author

nyuichi commented Aug 2, 2014

(picrin map)

; map class interface
map?
map-ref
map-set!
map-has?
map-delete!
map-for-each
map-map
map-size
map-empty?
map-clear!

; impls of map
make-hash-map
hash-map
make-tree-map
tree-map

@zeptometer
Copy link
Contributor

When those functions are given, I'm not sure what the word "map" means (map-map will make me mad!). Other words such as "dict" or "table" or etc is more suitable, aren't they?

@KeenS
Copy link
Member

KeenS commented Aug 3, 2014

How about having
map-size
map-empty?
map-clear

@nyuichi
Copy link
Member Author

nyuichi commented Aug 3, 2014

@zeptometer

I have some alternatives:

  • assoc. I think this is the best alternative among, but it is an abbreviation.
  • table. isn't it confusing with other tables (like EXCEL's table)?
  • dictionary. Since we have dictionaries as symbol-to-object hash table, we will need to rewrite the sources using old dictionaries; nevertheless, dictionary just suggests tables that looks up with string-like keys, not object-to-object tables.

idea?

@nyuichi
Copy link
Member Author

nyuichi commented Aug 3, 2014

@KeenS

Indeed!

@KeenS
Copy link
Member

KeenS commented Aug 3, 2014

@wasabiz @zeptometer
other alternatives are

  • hash. This is used in Ruby but as you know this is confusing with hash code, at least, not suitable for tree-map.
  • kvs. This exactly explain what it is but is also an abbreviation an initialism.

@nyuichi
Copy link
Member Author

nyuichi commented Sep 15, 2014

@stibear @KeenS @zeptometer

Hi, all.

Thinking this over for a month, I started to feel like changing dictionaries to object-to-object hashtable is not a bad idea. In the previous reply I complained about that idea by giving two reasons, and now I found they are solvable ones.

  1. Since we have dictionaries as symbol-to-object hash table, we will need to rewrite the sources using old dictionaries

I can find only a little uses of dictionary c APIs just by searching current sources codes. It will not require a big change.

  1. dictionary just suggests tables that looks up with string-like keys, not object-to-object tables.

Python uses the name "dictionary" to such object. This strongly encourages the change.

Please let me know your positions.

Thanks.

@nyuichi
Copy link
Member Author

nyuichi commented Sep 15, 2014

Implementation here: picrin-scheme/libpicrin#30

@zeptometer
Copy link
Contributor

I think that is natural extension. Well.. I wish there was way to designate equality: just eq?, eqv?, equal? is enough, like make-hash-table of Common Lisp.

@nyuichi
Copy link
Member Author

nyuichi commented Sep 15, 2014

@zeptometer

Hmm... I, kind of, agreed. But actually when you use dictionaries only with symbols you can get performance as nice as eq?-based hash tables. I'm not sure this is the case in future version some more eager optimization process say JIT is landed, though.

@KeenS
Copy link
Member

KeenS commented Sep 15, 2014

@wasabiz I'm for to make dictionary obj-obj map. If you have plan to introduce keywords to picrin, discuss performance then.

@nyuichi
Copy link
Member Author

nyuichi commented Sep 21, 2014

changed.

@nyuichi nyuichi closed this as completed Sep 21, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants