caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Christoph Höger" <christoph.hoeger@tu-berlin.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] let rec with let ref
Date: Fri, 18 Mar 2016 12:55:09 +0100	[thread overview]
Message-ID: <56EBEC9D.6070508@tu-berlin.de> (raw)
In-Reply-To: <20160318113654.GB18511@frosties>

You should use this variant:

let forloop g v u =
  let x = ref v in let rec h () = begin g !x; x := !x + 1; if !x <= u
then h ()
end
  in h;;

1. forloop does not need to be recursive (and is not a syntactical function)
2. h is not a syntactical function, but can easily be made one.
Recursive functions need to be syntactical functions (i.e.
lambda-abstractions) in order to correctly compile them.

regards,

Christoph

Am 18.03.2016 um 12:36 schrieb Goswin von Brederlow:
> let rec forloop g v u =
>> >   let x = ref v in let rec h = begin g !x; x := !x + 1; if !x <= u then h
>> > end
>> >   in h;;


-- 
Christoph Höger

Technische Universität Berlin
Fakultät IV - Elektrotechnik und Informatik
Übersetzerbau und Programmiersprachen

Sekr. TEL12-2, Ernst-Reuter-Platz 7, 10587 Berlin

Tel.: +49 (30) 314-24890
E-Mail: christoph.hoeger@tu-berlin.de

      reply	other threads:[~2016-03-18 11:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-17 15:32 Antoine Rimlet
2016-03-17 15:37 ` vrotaru.md
2016-03-18 11:36   ` Goswin von Brederlow
2016-03-18 11:55     ` Christoph Höger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56EBEC9D.6070508@tu-berlin.de \
    --to=christoph.hoeger@tu-berlin.de \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).