Loading ...
Sorry, an error occurred while loading the content.

Re: "ocaml_beginners"::[] comaring "apples" to "oranges" ?

Expand Messages
  • Sergei Steshenko
    ... 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) :
    Message 1 of 53 , Feb 26, 2013
    • 0 Attachment
      >________________________________
      > From: Gabriel Scherer <gabriel.scherer@...>
      >To: ocaml_beginners@yahoogroups.com
      >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
      >distinct type?
      >
      >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
      >typing information?
      >
      >(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
      >Javascript-like manipulations, such as the Brown PLT team:
      >http://blog.brownplt.org/2012/12/03/typing-first-class-field-names.html
      >)
      >


      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) :

      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]

      etc.

      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.

      Regards,
        Sergei.
    • Sergei Steshenko
      ... 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) :
      Message 53 of 53 , Feb 26, 2013
      • 0 Attachment
        >________________________________
        > From: Gabriel Scherer <gabriel.scherer@...>
        >To: ocaml_beginners@yahoogroups.com
        >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
        >distinct type?
        >
        >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
        >typing information?
        >
        >(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
        >Javascript-like manipulations, such as the Brown PLT team:
        >http://blog.brownplt.org/2012/12/03/typing-first-class-field-names.html
        >)
        >


        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) :

        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]

        etc.

        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.

        Regards,
          Sergei.
      Your message has been successfully submitted and would be delivered to recipients shortly.