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 SAA19615; Thu, 29 Jan 2004 18:41:52 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA19291 for ; Thu, 29 Jan 2004 18:41:51 +0100 (MET) Received: from eris.rz.uni-saarland.de (eris.rz.uni-saarland.de [134.96.7.8]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id i0THfoP24419 for ; Thu, 29 Jan 2004 18:41:50 +0100 (MET) Received: from cs.uni-sb.de (cs.uni-sb.de [134.96.254.254]) by eris.rz.uni-saarland.de (8.12.10/8.12.9) with ESMTP id i0THfo966944061 for ; Thu, 29 Jan 2004 18:41:50 +0100 (CET) Received: from mail.cs.uni-sb.de (mail.cs.uni-sb.de [134.96.254.200]) by cs.uni-sb.de (8.12.11/2003091100) with ESMTP id i0THfnXR014161 for ; Thu, 29 Jan 2004 18:41:49 +0100 (CET) Received: from ps.uni-sb.de (grizzly.ps.uni-sb.de [134.96.186.68]) by mail.cs.uni-sb.de (8.12.11/2003073000) with ESMTP id i0THfnNv029874 for ; Thu, 29 Jan 2004 18:41:49 +0100 (CET) X-Authentication-Warning: email: Host grizzly.ps.uni-sb.de [134.96.186.68] claimed to be ps.uni-sb.de Received: from ps.uni-sb.de (groove.ps.uni-sb.de [134.96.186.172]) by ps.uni-sb.de (8.12.10/8.12.10) with ESMTP id i0THfln2007764; Thu, 29 Jan 2004 18:41:47 +0100 Message-ID: <401945DB.4030106@ps.uni-sb.de> Date: Thu, 29 Jan 2004 18:41:47 +0100 From: Andreas Rossberg User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1) Gecko/20031114 X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: fancy types (was Re: [Caml-list] ocaml killer) References: <20040127063230.GA12482@inv_machine> <200401282326.i0SNQntl004612@bismarck-chet.watson.ibm.com> <40184A2F.6040007@dcs.qmul.ac.uk> <200401290000.i0T00ntl006988@bismarck-chet.watson.ibm.com> <40184FB9.4000808@dcs.qmul.ac.uk> <200401290034.i0T0Yutl009000@bismarck-chet.watson.ibm.com> <20040129162048.GA29094@force.stwing.upenn.edu> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; rossberg:01 rossberg:01 uni-sb:01 caml-list:01 val:01 stupid:01 faq:01 -rectypes:01 -rectypes:01 tagging:01 dynamically:01 uni-sb:01 darkened:01 munching:01 repetitive:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Thomas Fischbacher wrote: > > Look here: > > # let fac n = let do_rec specialist n = if n = 0 then 1 else n * specialist specialist (n-1) in do_rec do_rec n;; > > Characters 74-84: > let fac n = let do_rec specialist n = if n = 0 then 1 else n * > specialist specialist (n-1) in do_rec do_rec n;; > > ^^^^^^^^^^ > This expression has type 'a -> 'b -> 'c but is here used with type 'a > > # let fac n = let do_rec specialist n = if n = 0 then 1 else n * (Obj.magic specialist) specialist (n-1) in do_rec do_rec n;; > val fac : int -> int = > > # fac 8;; > - : int = 40320 > > This is just one stupid example where the type system gets in the way > while it should not. This is almost an FAQ. Try "ocaml -rectypes". Note that there are very good reasons for this being an option, since it is almost never practically useful, but can lead to "false negatives" (code getting accepted although it is plain nonsense) quite easily. Also note that you can encode most of these examples without -rectypes, using variant types. >>(which already exists in the standard library, it being >>mysteriously named Obj.magic and its use being highly discouraged). > > For good. I bet this feature exists precisely to keep the LISP wizards > happy who know about and are not afraid of these dark corners, and have > (maybe out of stubbornness :-) ) a strong desire writing LISP code in > ocaml. No, it is rather there for hacking C bindings and stuff. > BTW: I also strongly assume that internally, ocaml uses type tagging > anyway, at least for the garbage collector; hence it may be possible to > use just the engine of ocaml and build a dynamically typed lisp on top of > it...? No, it uses only 1-bit tags. - Andreas -- Andreas Rossberg, rossberg@ps.uni-sb.de "Computer games don't affect kids; I mean if Pac Man affected us as kids, we would all be running around in darkened rooms, munching magic pills, and listening to repetitive electronic music." - Kristian Wilson, Nintendo Inc. ------------------- 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