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 OAA05630; Fri, 23 Apr 2004 14:56:17 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 OAA05623 for ; Fri, 23 Apr 2004 14:56:16 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i3NCuEYM004318; Fri, 23 Apr 2004 14:56:14 +0200 Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA05593; Fri, 23 Apr 2004 14:56:14 +0200 (MET DST) Date: Fri, 23 Apr 2004 14:56:14 +0200 From: Xavier Leroy To: Martin Jambon Cc: caml-list@inria.fr Subject: Re: [Caml-list] Suggestion: Pervasives.identity Message-ID: <20040423145614.C3686@pauillac.inria.fr> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: ; from martin_jambon@emailuser.net on Fri, Apr 23, 2004 at 08:18:21PM +0800 X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 pervasives:01 combinators:01 pervasives:01 black:98 readable:01 external:03 external:03 unit:03 let:04 compiled:05 compiled:05 efficient:05 seems:05 generally:05 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Is there a good why there is no predefined identity function? A good reason, yes: it's generally useless. There are no predefined S and K combinators either :-) > (fun x -> x) is sometimes less readable, and seems to be not > compiled (yet?) as this black magic: > external identity : 'a -> 'a : "%identity" Even if you define external identity: 'a -> 'a = "%identity" references to "identity" will be compiled like "fun x -> x". It's only direct applications of "identity", e.g. "identity 3", that would be more efficient than with the definition let identity x = x But I hope your programs don't contain calls like "identity x"... > In the same style, we already have Pervasives.ignore, so why not > Pervasives.identity? Because Pervasives.ignore is very useful and commonly used to deal with the "should have type unit" warning. - Xavier Leroy ------------------- 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