I am attempting to learn OCaml by using compiled code instead of the top-level; however, much of the sample code online seems to appeal to the latter.
I would like to create a new Foo within a method of an object per below. This code does not compile, citing a syntax error with the doFooProc definition.
class bar =
object (self)
method doFooProc = (new Foo "test")#process
end;;
class foo (param1:string)=
object (self)
method process = Printf.printf "%s\n" "Processing!"
initializer Printf.printf "Initializing with param = %s\n" param1
end;;
Additionally, the "let" syntax don't seem to be friendly within class definitions. Why is that?
class bar =
object (self)
method doFooProc =
let xxx = (new Foo "test");
xxx#process
end;;
class foo (param1:string)=
object (self)
method process = Printf.printf "%s\n" "Processing!"
initializer Printf.printf "Initializing with param = %s\n" param1
end;;
How do I go about creating a new object of class foo in the doFooProc method and call the instantiated foo's process command?