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 TAA17303; Thu, 12 Apr 2001 19:51:24 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA17370 for ; Thu, 12 Apr 2001 19:51:23 +0200 (MET DST) Received: from smtp8.xs4all.nl (smtp8.xs4all.nl [194.109.127.134]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f3CHpMT27404 for ; Thu, 12 Apr 2001 19:51:22 +0200 (MET DST) Received: from beertje.william.bogus (williamc.xs4all.nl [213.84.56.92]) by smtp8.xs4all.nl (8.9.3/8.9.3) with ESMTP id TAA01266; Thu, 12 Apr 2001 19:51:18 +0200 (CEST) Received: (from williamc@localhost) by beertje.william.bogus (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) id f3CHror06265; Thu, 12 Apr 2001 19:53:50 +0200 X-Authentication-Warning: beertje.william.bogus: williamc set sender to williamc@paneris.org using -f From: William Chesters MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15061.60329.582779.649419@beertje.william.bogus> Date: Thu, 12 Apr 2001 19:53:45 +0200 (CEST) To: Mattias Waldau , Subject: Re: [Caml-list] How do I define prog1? In-Reply-To: References: X-Mailer: VM 6.75 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, 12 Apr 2001, Mattias Waldau wrote: > I would like to define a (prog1 a b) which first evaluates a, then b, and > returns the > value of a. (Would be nice if I could have arbitrary number of args.) camlp4 is the natural tool here; I did it once: open Pcaml open MLast EXTEND GLOBAL: expr ctyp patt class_str_item module_expr; expr: [[ res = expr (* LEVEL "expr1" *); "before"; post = LIST1 expr SEP ";" -> <:expr< let __it = $res$ in do $list:post$ return __it >> ]] ; END I think this lets you write e.g. let a = ref 1 and b = ref 10 in !a + !b before incr a; incr b => 11 but I can't see any examples of it in my old code and I don't have campl4 installed to test it, sorry ... ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr