SWI-Prolog / roadmap

Discuss future development
21 stars 3 forks source link

Hashtable Blobs #44

Closed TeamSPoon closed 8 years ago

TeamSPoon commented 8 years ago

Hashtable Blobs supporting the same operations as gvars

TeamSPoon commented 8 years ago

What this means is

?- make_hashtable_blob(X). X = <hashtable>(0xb4df00d).

?- b_setval($X,key,value), b_getval($X,key,Value). Value = value.

?- release_hashtable($X).

I know.. why do we need yet another dictionary type?! There are several way to do the above currently such as concatenation into the keyname arg of gvars.

I think the attraction to me is that the C hashtable code is so dang cool it seems like it should be leveragable from prolog! Also if someone else writes this.. I'll finally understand how to make blobtypes around that type of foreign object.

JanWielemaker commented 8 years ago

Global variables use this. It is quite a nightmare inside GC, but was necessary considering the semantics of the "Leuven" global variables. There is no point though. As these things refer to terms on the stacks, the whole concurrency trick of Keri's tables is irrelevant. Hash tables can be perfectly implemented in Prolog. If desirable we can speedup a little by doing the low-level stuff in C, but manipulating terms on the stack. See library(nb_set).