From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA28615; Fri, 31 May 2002 17:39:08 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA28566 for ; Fri, 31 May 2002 17:39:07 +0200 (MET DST) Received: from cs.bu.edu (cs.bu.edu [128.197.12.2]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g4VFd5n00945; Fri, 31 May 2002 17:39:06 +0200 (MET DST) Received: from csa.bu.edu (zhudp@csa [128.197.12.3]) by cs.bu.edu (8.12.2/8.12.2) with ESMTP id g4VFd5F2015604; Fri, 31 May 2002 11:39:05 -0400 (EDT) Received: from localhost (zhudp@localhost) by csa.bu.edu (8.10.1/8.10.1) with ESMTP id g4VFd2Z04359; Fri, 31 May 2002 11:39:02 -0400 (EDT) X-Authentication-Warning: csa.bu.edu: zhudp owned process doing -bs Date: Fri, 31 May 2002 11:39:02 -0400 (EDT) From: dengping zhu X-Sender: zhudp@csa.bu.edu To: Daniel de Rauglaudre cc: Ocaml Subject: Re: [Caml-list] about Obj.magic In-Reply-To: <20020531060028.A31866@verdot.inria.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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