From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 8422FD460 for ; Tue, 25 Oct 2005 03:43:36 +0200 (CEST) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j9P1hYBs025570 for ; Tue, 25 Oct 2005 03:43:35 +0200 Received: from rosella (ppp14-90.lns2.syd7.internode.on.net [59.167.14.90]) by smtp1.adl2.internode.on.net (8.12.9/8.12.6) with ESMTP id j9P1hMd1042147; Tue, 25 Oct 2005 11:13:24 +0930 (CST) (envelope-from skaller@users.sourceforge.net) Subject: Re: [Caml-list] how to implement generic operators From: skaller To: Jacques Carette Cc: caml-list@yquem.inria.fr In-Reply-To: <435D35B7.2080905@mcmaster.ca> References: <1130131250.28443.79.camel@rosella> <435D35B7.2080905@mcmaster.ca> Content-Type: text/plain Date: Tue, 25 Oct 2005 11:43:22 +1000 Message-Id: <1130204602.18325.54.camel@rosella> Mime-Version: 1.0 X-Mailer: Evolution 2.2.1.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 435D8DC6.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 subset:01 ocaml:01 syntax:01 lambdas:01 recursion:01 inlining:01 ...:98 lambda:01 wrote:01 wrote:01 sourceforge:01 unbound:01 evaluator:01 jacques:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Mon, 2005-10-24 at 15:27 -0400, Jacques Carette wrote: > skaller wrote: > You really need your operations to be left-associative for that to make > sense... But in my toy interpreter for a subset of Maple (written in > Ocaml), I have > type op = term -> term -> term * term > and then in the eval() function for a term, a case > | Assoc ((f,init), l) -> List.fold_left f init l > > f can be created from a term by applying a term-level lambda, I am already doing this for types. There is also a separate programmable term evaluator however it works only on the syntax tree (unbound terms). My type term calculus has lambdas and products .. but no lists. There is no real 'term' calculus (just ad hoc reduction rules**). Do you provide lists directly in the term calculus? Or are they just constructed from products and sums? It looks like I would have to (1) provide a term calculator (1a) extend the type calculator to support either lists or (1b) add sums and make sure recursion works 1a looks easier, clearly 1b is more general. ** the 'ad hoc' reduction rules are 'weak' things like constant folding, plus some sophisticated but very specialised rules for inlining and substitution: there is no way I could really claim this 'term calculator' I already have is a general 'calculus', in the same way that the type calculator is. -- John Skaller Felix, successor to C++: http://felix.sf.net