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

1570Re: "ocaml_beginners"::[] Parameterized Classes

Expand Messages
  • Remi Vanicat
    Feb 3 11:00 PM
    • 0 Attachment
      "dpthayer2004" <methayer@...> writes:

      > I have a class I have created that takes three parameters
      >
      > class lc_classifier
      > (condition:lc_condition)
      > (_action:lc_action)
      > (_params:lc_exp_params) = ...etc
      >
      > When I use this class at some other point of my program
      >
      > i.e.
      >
      > (*Create a population with n randomized classifiers*)
      > method populate n =
      > let c = params#get_cond_size;
      > and g = params#get_generality;
      > and a = params#get_actions_num;
      > in
      > for i = 1 to n do
      > let cnd = LC_Condition ( random_condition c g);
      > and act = LC_Action( random_action a);
      > in
      > let p = new lc_classifier cnd act params
      > in
      > self#insert_classifier p;
      > done
      >
      > which is a method n a different class I am getting the followng
      > error message when I try to load it in the OCaml Interpreter.
      >
      > File "G:/OCaml/LCS_Population.ml", line 64, characters 36-39:
      > This expression has type lc_condition but is here used with type
      > lc_condition The line triggering the error is

      This is because you define the type lc_condition at least two
      time. Ocaml don't give you warning when you do it (may be it should),
      but thus strange error message when you use something of one of the
      type when you mean the other. So you have to look where is the
      multiple definition of the lc_condition type, knowing the fact that a
      class definition is at the same time a type definition.

      Hope that help.

      --
      RĂ©mi Vanicat
    • Show all 2 messages in this topic