Re: "ocaml_beginners":: comaring "apples" to "oranges" ?
On Mon, Feb 25, 2013 at 7:46 AM, Sergei Steshenko <sergstesh@...>wrote:
> And in my case this wrapped type works as expected: ...
Yes, but this is not analogous, int_1 and float_1 are of the same type, as
where 1 and 1.0 are not.
[Non-text portions of this message have been removed]
>________________________________First of all, I want both non-homogenous keys and non-homogenous values, i.e. I want top be able in the same hash to have (I know the code won't compile) :
> From: Gabriel Scherer <gabriel.scherer@...>
>Sent: Tuesday, February 26, 2013 5:20 PM
>Subject: Re: "ocaml_beginners":: comaring "apples" to "oranges" ?
>I'm not sure I have fully understood this length and
>unequally-productive discussion, so let me ask a question: what you
>are trying to do is to have a static disciplines for things that are
>not homogeneous hash tables (all keys store values of the same type),
>but heterogeneous hash tables where each key may store values of a
>The closest thing in the type system are object types (extensible
>types that have fields of different types). But different types can
>only be used if the access patterns are *statically* known, that is if
>the keys used (`one`, `two` in your example) are constants in the code
>rather than dynamically decided. (Of course in some cases you may pass
>acessors functions to be applied to the object). Do you think you can
>respect this expressivity restriction, in exchange for better static
>(Putting my theoretician hat on: there has been research on more
>dynamic associative structures. OCaml object types are based on row
>type variables, whose related uses on extensible records have been
>studied, for example, by Didier Rémy in the early nineties, Daan
>Leijen in the 2000's, and recently folks trying to do static typing on
let h = Hashtbl.create 16
Hashtbl.replace h 1 "one"
Hashtbl.replace "two" 2
Hashtbl.replace 3.0 "three"
Hashtbl.replace [1;2;3] "some_list"
Hashtbl.replace "another_list" [1; "two"; 3.0]
Regarding theoretical work and work done by others - I definitely know you professional guys have much deeper understanding and knowledge than I, but in this case I _myself_ need to step on all the required rakes - otherwise I won't learn and won't understand.
That is, reinvention of wheels and stepping on rakes are at the moment my explicit goals.