caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: dengping zhu <zhudp@cs.bu.edu>
To: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
Cc: Ocaml <caml-list@inria.fr>
Subject: Re: [Caml-list] about Obj.magic
Date: Fri, 31 May 2002 11:39:02 -0400 (EDT)	[thread overview]
Message-ID: <Pine.SOL.4.20.0205311117490.1622-100000@csa.bu.edu> (raw)
In-Reply-To: <20020531060028.A31866@verdot.inria.fr>

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


  parent reply	other threads:[~2002-05-31 15:39 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-30 21:09 dengping zhu
2002-05-30 22:38 ` Jacques Garrigue
2002-05-31  4:00 ` Daniel de Rauglaudre
2002-05-31  5:37   ` Oleg
2002-05-31  6:17     ` Daniel de Rauglaudre
     [not found]       ` <p05100300b91cea02dbf5@[192.168.1.22]>
2002-05-31  9:50         ` [Caml-list] SML->OCaml (was: about Obj.magic) Daniel de Rauglaudre
2002-05-31 15:39   ` dengping zhu [this message]
2002-05-31 16:28     ` [Caml-list] about Obj.magic John D. Barnett
2002-06-01  8:37     ` Jacques Garrigue
2002-06-01 16:00       ` dengping zhu
2002-06-01 17:20         ` Pierre Weis
2002-05-31  9:17 ` Warp
2002-05-31 13:58   ` Jacques Garrigue
2002-05-31 14:06     ` Warp
2002-05-31 18:21       ` John Max Skaller
2002-06-01 17:42         ` Pierre Weis
2002-06-02 15:15           ` John Max Skaller
     [not found]           ` <D37FA3E3-763B-11D6-BE8F-0003938819CE@inria.fr>
2002-06-04 10:22             ` Pierre Weis
2002-05-31 14:10     ` Remi VANICAT
2002-05-31 16:19     ` Christophe TROESTLER
2002-05-31 18:06       ` Olivier Andrieu
2002-05-31 22:03         ` Christophe TROESTLER

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.SOL.4.20.0205311117490.1622-100000@csa.bu.edu \
    --to=zhudp@cs.bu.edu \
    --cc=caml-list@inria.fr \
    --cc=daniel.de_rauglaudre@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).