[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | dengping zhu <zhudp@c...> |
| Subject: | Re: [Caml-list] about Obj.magic |
Hi, thanks for all you guys. After carefully checking my code, I tried to remove Obj.magic from my code. Anyway, at last I have to keep one which is not the case you guys mentioned. My code is very simple: ----------- type ty = ty1 -> ty2 (* where ty1, ty2 are some types I defined before, ty1 is some type like g * h, while ty2 likes c * d * e * f. *) let x = (f (g)) a ----------- Here, f and g are functions, and the return type of (f (g)) is ty, which is a function type ty1 -> ty2. While, the type of a is ty1. So, the return type of (f (g)) a should be ty2. Anyway, every time I get an error here. The error message is: You applied too many parameters... I was very surprised. After I removed a, then it is all right and the return type is ty. So, I was thinking that the compiler treated ty as an atomic type, not a function type. Then I have to use 'Obj.magic' here. Anyway, the result with 'Obj.magic' is correct. Probablely I was wrong here, but I'd like to get the help from you. Regards, Dengping On Fri, 31 May 2002, Daniel de Rauglaudre wrote: >Hi, > >On Thu, May 30, 2002 at 05:09:43PM -0400, dengping zhu wrote: > >> When should I use 'Obj.magic'? It is really confusing. Now I am >> converting a bunch of code from sml to ocaml. [...] > >About conversion from SML into OCaml, I may help: these days, I am >trying to convert a program of 70000 lines of SML into OCaml, using >Camlp4. Please ask me if you want more details. > >About examples of use Obj.magic, there are the extensible grammars of >Camlp4, and in particular the EXTEND function. I can explain here if >people are interested. And I know that the OCaml toplevel program uses >it also. > >In general, like Jacques Garrigue said, don't use Obj.magic if you are >not *absolutely* sure of what you do. > >-- >Daniel de RAUGLAUDRE >daniel.de_rauglaudre@inria.fr >http://cristal.inria.fr/~ddr/ >------------------- >To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr >Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ >Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners