From: Nicolas C. <war...@fr...> - 2004-04-25 20:15:24
|
> Hi, > > under Lisp there are to very useful functions `put' and > `get'. Emacs, C-h f put RET -> > > put is a built-in function. > (put SYMBOL PROPNAME VALUE) > > Store SYMBOL's PROPNAME property with value VALUE. > It can be retrieved with `(get SYMBOL PROPNAME)'. > > Eg: > > (put 'car 'ccm 1500) > (put 'car 'color 'silver) > (put 'car 'owner "Joe") > > (get 'car 'owner) > => "Joe" > > This functionality is something different than hashtabels. > A Hashtable has a type ('a,'b) Hashtbl.t and 'b is fix. > > With static typed OCaml it's tricky to implement put and get, but it's > possible. I needed something like this and Alain Frisch referred me to this > old mail [...] It looks interesting, although I didn't need theses before. Some comments : - polymorphic is better than functors (more usable and better perfs as Martin said) - there should be a way to retreive all the objects from a table and all the properties from an object - properties should be "closures" over objects so we doesn't need 2 arguments on put/get - better would be to have a recursive data structure so properties can themself be objects :-) Regards, Nicolas Cannasse |