From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 43A81BC6B for ; Sun, 25 Nov 2007 15:21:53 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAANcTSUfRVca7kmdsb2JhbACPPwEBAQEHBAQJChY X-IronPort-AV: E=Sophos;i="4.21,463,1188770400"; d="scan'208";a="19651360" Received: from rv-out-0910.google.com ([209.85.198.187]) by mail4-smtp-sop.national.inria.fr with ESMTP; 25 Nov 2007 15:21:52 +0100 Received: by rv-out-0910.google.com with SMTP id k20so346546rvb for ; Sun, 25 Nov 2007 06:21:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:reply-to:to:subject:date:user-agent:cc:references:in-reply-to:content-type:content-transfer-encoding:content-disposition:message-id; bh=P5j8CaRFvBNa2a1+cyhr0HZIJpxP8o3+CdaIcua5WUQ=; b=huf+ERMb2dPmNoetNMErTjo1efVe5qQpldDNitABq76K84gOqPF3UEibWhEmunBWnNBEKoJg67UAQu+ejFq14eehk3mbxl/tChjWxiepLx1EM3E+H2mP2wRi/ZwDaxfYKjvJfjbn1EyHTLRTmHnkD9XYpe/5DCuOhHspMnOdd4U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=received:from:reply-to:to:subject:date:user-agent:cc:references:in-reply-to:content-type:content-transfer-encoding:content-disposition:message-id; b=BnBk/7ogg47kAQvKNyNDF/Lvnq1zxQKs8cWFu92j/latWHRrkGEqgYtdGyRlovW7M6UGiJzK91ytUdQBcJ1WXmMlWrj9GuE1q5BK+JMHA//10iRBJ2qFrarjuedmf9TQxU+Ep/f4SPiOcyQk4LhOVfA56BTbsa8SybZ4h78EfHw= Received: by 10.141.180.5 with SMTP id h5mr628759rvp.1196000511425; Sun, 25 Nov 2007 06:21:51 -0800 (PST) Received: from tama-chan ( [24.99.180.210]) by mx.google.com with ESMTPS id l43sm156121wrl.2007.11.25.06.21.49 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 25 Nov 2007 06:21:49 -0800 (PST) From: Peng Zang Reply-To: peng.zang@gmail.com To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] weird behavior with built-in ignore function (a bug?) Date: Sun, 25 Nov 2007 09:21:40 -0500 User-Agent: KMail/1.9.7 Cc: Julien Moutinho References: <200711231109.47460.peng.zang@gmail.com> <200711241348.22594.peng.zang@gmail.com> <20071125060549.GA6395@localhost> In-Reply-To: <20071125060549.GA6395@localhost> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200711250921.46365.peng.zang@gmail.com> X-Spam: no; 0.00; bug:01 hash:01 bug:01 externally:01 compiler:01 bytecomp:01 translcore:01 asmcomp:01 cmmgen:01 transl:01 pervasives:01 ocamlopt:01 ocamlopt:01 ocaml:01 val:01 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Thanks for the link to that thread and the examples, it was very helpful. Peng On Sunday 25 November 2007 01:05:49 am Julien Moutinho wrote: > On Sat, Nov 24, 2007 at 01:48:18PM -0500, Peng Zang wrote: > > Ahhh... it's good to know this is a bug and that it has been fixed. I > > think for the interim I will simply define my own ignore function. It > > also bothers me that even in the fixed version ignore does not equal > > itself. > > Have a glance at this little thread: > > http://caml.inria.fr/pub/ml-archives/caml-list/2005/04/838a1399a42491c4db9a >eaa684458a6b.en.html > > > I also don't see why ignore is even defined externally. > > Doesn't the compiler optimize ignore calls away? > > Well, in bytecomp/translcore.ml in the primitives_table > "%ignore" is associated with Pignore > > and in asmcomp/cmmgen.ml: > | Pignore -> > > return_unit(remove_unit (transl arg)) > > So I guess Pervasives.ignore is defined like that > to be able to segregate it at compile time to avoid > a function call. > > % cat t.ml > ignore (Random.bits ()) > > % ocamlopt -dcmm t.ml > [...] > (function camlT__entry () > (app{random.ml:157,14-32} "camlRandom__bits_89" (load (+a "camlRandom" > 52)) unit) > 1a) > [...] > > > % cat tt.ml > let ignore _ = () > in ignore (Random.bits ()) > > % ocamlopt -dcmm tt.ml > [...] > (data int 2295 "camlTt__1": addr "camlTt__ignore_58" int 3) > (function camlTt__ignore_58 (x/59: addr) 1a) > > (function camlTt__entry () > (let ignore/58 "camlTt__1" > (app{random.ml:157,14-32} "camlRandom__bits_89" > (load (+a "camlRandom" 52)) unit)) > 1a) > [...] > > > BTW that's the use of return_unit which disables tail-rec optimization: > % ocaml > Objective Caml version 3.10.1+dev2 (2007-11-20) > > # let rec f () = ignore (f ());; > val f : unit -> unit = > # f ();; > Stack overflow during evaluation (looping recursion?). > > # let rec f () = f ();; > val f : unit -> 'a = > # f ();; > Interrupted. > > # let rec f () = let _ = f () in ();; > val f : unit -> unit = > # f ();; > Stack overflow during evaluation (looping recursion?). > > # let rec f () : unit = Obj.magic (f ());; > val f : unit -> unit = > # f ();; > Interrupted. > > Regards, > Julien. > > _______________________________________________ > 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 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) iD8DBQFHSYT6fIRcEFL/JewRAj6eAJ49xNEBIF37V/rC56wlJmApUPkmMwCgo3K4 /8yXSailKazYrspH57e29u8= =rGYM -----END PGP SIGNATURE-----