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 EAA28625; Sat, 24 Apr 2004 04:09:14 +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 EAA28604 for ; Sat, 24 Apr 2004 04:09:11 +0200 (MET DST) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i3O298YM017092 for ; Sat, 24 Apr 2004 04:09:09 +0200 Received: from [192.168.1.200] (ppp119-113.lns1.syd2.internode.on.net [150.101.119.113]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i3O292Zq071990; Sat, 24 Apr 2004 11:39:03 +0930 (CST) Subject: Re: [Caml-list] Suggestion: Pervasives.identity From: skaller Reply-To: skaller@users.sourceforge.net To: Brian Hurt Cc: Martin Jambon , caml-list In-Reply-To: References: Content-Type: text/plain Message-Id: <1082772541.21205.665.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 24 Apr 2004 12:09:02 +1000 Content-Transfer-Encoding: 7bit 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 sourceforge:01 2004:99 pervasives:01 stupid:01 expr:01 expr:01 implemented:01 optimise:01 9660:01 glebe:01 compiler:01 nsw:01 snail:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sat, 2004-04-24 at 01:48, Brian Hurt wrote: > On Fri, 23 Apr 2004, Martin Jambon wrote: > > > > In the same style, we already have Pervasives.ignore, so why not > > Pervasives.identity? > Possibly stupid question: what use would this function be? I use it with higher order functions. For example I have a function: type typed_expr = expr_t * type_t map_typed_expr: (expr_t -> expr_t) -> (type_t -> type_t) -> typed_expr_t -> typed_expr_t Sometimes I wish to map only the typing in an expression, and sometimes only the expression terms not the typing. So I pass 'identity' as one of the arguments. An identity function would also be useful in machine generated code in a situation similar to the above where the HOF was implemented in the code generator, and you don't want to specialise the generator but would rather the target compiler optimise the application of 'identity' away. So it is 'useful' -- but this is no argument it should be in Pervasives. -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- 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