Reply to topic  [ 2 posts ] 
yeti hash table API regression 
Author Message
Yorick Master

Joined: Sun Sep 26, 2004 10:33 am
Posts: 150
Location: Australia
Post yeti hash table API regression

ERROR (*main*) expecting or a single hash key name or nil (integer indexing no longer supported)

I see that as a relatively serious regression. Some of my functions that were using hash tables are now broken. Why did you remove support for integer indexing??? May be I missed something and there is an easy workaround?

Tue May 04, 2010 8:59 am
Profile WWW
Yorick Guru

Joined: Wed Nov 24, 2004 12:51 pm
Posts: 98
Location: Observatoire de Lyon (France)
Integer indexing of hash table is both inefficient (finding the n-th entry amounts to follow the n first entries) and non reproducible (the order change when entries get removed or inserted). I have marked this as a "feature" to be removed in the documentation from the very beginning.

I can see no good reason to use integer indices for hash table. If you want to index hash table in the current order of its keys, it is better to use first_key and next_key:
for (key = h_first(tab); key ; key =h_next(tab, key)) {
  value = h_get(tab, key);
which is much more efficient then
n = h_number(tab);
for (i = 1; i <= n; ++i) {
  value = h_get(tab, i);
On the other hand if you want to use integers as hash keys, you can use their human readable value coded into a string, e.g. key = swrite(format="%d",i).

If there are good reason to use indices I can reintroduce them (maybe you can provide an example that could be shown in the documentation). But I really think it is not a good idea as it would encourage mis usage of hash table.

Sun May 09, 2010 10:33 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.