class base_model = object(self)
method from_array ary = ...
end ;;
class user = object(self)
inherit base_model
...
end ;;
let finder sql class_type =
query_database sql ;
let res = new class_type in
res#from_array res ;;
let users = finder "SELECT * FROM users" user in
xxx yyy ;;
Ok. That is not working code, prob has syntax errors as well, but you
get my idea. The problem I am having is passing the class to the
generic finder method.
Thanks,
Jeremy
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
No, you can't, but you can pass the class constructor in place, which
is just equivalent.
let finder sql class_new =
query_database sql ;
let res = class_new () in
res#from_array res ;;
let users = finder "SELECT * FROM users" (fun () -> new user) in
xxx yyy ;;
Note that in general the class constructor takes arguments, so you
don't need the above anonymous function.
Jacques Garrigue