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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id DA32CBC37 for ; Wed, 10 Feb 2010 01:07:05 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmkDAPCHcUtV2gB4h2dsb2JhbACDCZdxAQEBCgsIBxUjrT6QNoEvgkpbBIla X-IronPort-AV: E=Sophos;i="4.49,439,1262559600"; d="scan'208";a="44360707" Received: from emailfrontal1.citycable.ch ([85.218.0.120]) by mail3-smtp-sop.national.inria.fr with SMTP; 10 Feb 2010 01:07:05 +0100 Received: from [192.168.0.12] (unknown [85.218.92.99]) (Authenticated sender: guillaume.yziquel@citycable.ch) by emailfrontal1.citycable.ch (Postfix) with ESMTPA id 1778112C17C; Wed, 10 Feb 2010 01:07:03 +0100 (CET) Message-ID: <4B71F8C3.5080306@citycable.ch> Date: Wed, 10 Feb 2010 01:07:31 +0100 From: Guillaume Yziquel Reply-To: guillaume.yziquel@citycable.ch User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090707) MIME-Version: 1.0 To: Gerd Stolpmann Cc: saptarshi.guha@gmail.com, caml-list@yquem.inria.fr Subject: Re: [Caml-list] The need to specify 'rec' in a recursive function defintion References: <1e7471d51002091250of7a686fq537a03c9401c868f@mail.gmail.com> <1265752863.5482.42.camel@flake.lan.gerd-stolpmann.de> <4B71DA88.8040902@citycable.ch> <1265754854.5482.44.camel@flake.lan.gerd-stolpmann.de> In-Reply-To: <1265754854.5482.44.camel@flake.lan.gerd-stolpmann.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; guillaume:01 guillaume:01 recursive:01 defintion:01 gerd:01 stolpmann:01 gerd:01 stolpmann:01 recursion:01 inference:01 existential:01 ocaml:01 'let:01 rec':01 recursion:01 Gerd Stolpmann a =C3=A9crit : > Am Dienstag, den 09.02.2010, 22:58 +0100 schrieb Guillaume Yziquel: >> Gerd Stolpmann a =C3=A9crit : >>> Am Dienstag, den 09.02.2010, 15:50 -0500 schrieb Saptarshi Guha: >>> >>> Besides the different way of defining "let" and "let rec" there are a= lso >>> differences in typing. >=20 > Well, at least you can have new effects. Look for "polymorphic > recursion". You mean something like this? http://alaska-kamtchatka.blogspot.com/2009/05/polymorphic-recursion.html With the following code > type length =3D { length : 'a . int -> 'a vec -> int } >=20 > let length v =3D > let rec f =3D { length =3D fun n l -> match l with > Nil -> n > | Zero ps -> f.length ( 2 * n) ps > | One (_, ps) -> f.length (1 + 2 * n) ps > } in f.length 0 v you get to use a function, here f.length, in two different contexts for=20 type inference, allowing it to be used with multiple types? 'a * 'a=20 instead of 'a? Am I getting this post right? But then, this seems to go into rather elaborate constructions=20 (existential types with OCaml records), which are quite remote from the=20 simple 'let rec' issue we were talking about. Is it possible to have polymorphic recursion with vanilla 'let rec'=20 invocations? Or am I getting you wrong? All the best, --=20 Guillaume Yziquel http://yziquel.homelinux.org/