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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id F1D71BC37 for ; Tue, 9 Feb 2010 21:58:27 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoBAJ9bcUvRVdzgkGdsb2JhbACDM5dTPAEBAQEJCQwHEwOteS4KgUCFQIhxAQEDBYEqgkpbBIsu X-IronPort-AV: E=Sophos;i="4.49,438,1262559600"; d="scan'208";a="52227554" Received: from mail-fx0-f224.google.com ([209.85.220.224]) by mail1-smtp-roc.national.inria.fr with ESMTP; 09 Feb 2010 21:58:27 +0100 Received: by fxm24 with SMTP id 24so1203334fxm.3 for ; Tue, 09 Feb 2010 12:58:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:reply-to:from:date :message-id:subject:to:content-type; bh=LeDwHgNEeGpBRR9k4CKgVhTkE2AaE8iFD3vMoc7DLMk=; b=vygmF0shEDzb/zaixfQ9JSDs0kiwOM+PtYGNGWCmpx9o/RH28tZPD+Y996PwvjjQji zGutXpCUFv3nMB9e4ggM/ACQ50rMs8NdvjyY4OXduRVO1NrQQKggqqcFBtkyRToaIPF9 n4KpXDv3q4d6eDrRoYQqCHbBOsfQAEhzpfhUY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:from:date:message-id:subject:to:content-type; b=tb3fsWUXERqNvc76ncxP0k8z9/5ASd2BgFhMH8UPUzKiFTqMKtrYRlZZP2g0YWN733 Z89pFSerk7ujPwBaG6qz4ckAGDS0SvC0QUltbxKzFsb0qME4thcl9c9AgwNnIoCY+p53 nBDCCj8udFEVucmqJDJgoija0BOyWkAb5yzmM= MIME-Version: 1.0 Received: by 10.239.173.84 with SMTP id d20mr931812hbf.41.1265748653228; Tue, 09 Feb 2010 12:50:53 -0800 (PST) Reply-To: saptarshi.guha@gmail.com From: Saptarshi Guha Date: Tue, 9 Feb 2010 15:50:33 -0500 Message-ID: <1e7471d51002091250of7a686fq537a03c9401c868f@mail.gmail.com> Subject: The need to specify 'rec' in a recursive function defintion To: caml-list@yquem.inria.fr Content-Type: text/plain; charset=UTF-8 X-Spam: no; 0.00; recursive:01 defintion:01 recursive:01 ocaml:01 compiler:01 compiler:01 ocaml:01 beginners':01 unbound:01 rec:01 rec:01 functions:01 tail:01 defined:02 optimization:03 Hello, I was wondering why recursive functions need to be specified with "rec". According to Practical Ocaml, to "inform the compiler that the function exists". But when entering the function definition, can't the compiler note that the function is being defined so that when it sees the function calling itself, it wont say "Unbound value f"? How is the knowledge of a function being rec taken advantage of (in ocaml) as opposed to other languages (leaving aside tail call optimization). Wouldn't one of way of detecting a recursive function would be to see if the indeed the function calls itself? These are very much beginners' questions. Thank you Saptarshi