From: Bruno De Fraine <Bruno.De.Fraine@vub.ac.be>
To: Jon Harrop <jon@ffconsultancy.com>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] How important are circular lists/recursive objects?
Date: Tue, 3 Apr 2007 15:31:51 +0200 [thread overview]
Message-ID: <2F51D421-AFAD-42F4-8DE5-E6416EC03CAB@vub.ac.be> (raw)
In-Reply-To: <200704031309.08302.jon@ffconsultancy.com>
Hello Jon,
On 03 Apr 2007, at 14:09, Jon Harrop wrote:
> Specifically, in the "eval" function:
>
> | ELetRec(var, arg, body, rest) ->
> let rec vars = (var, VClosure(arg, vars, body)) :: vars in
> eval vars rest
Actually, I think this critical piece of code is incorrect. As such,
the new "vars" is shadowing the old value of "vars", while it seems
you still want to refer to this old value in one place. I.e.:
| ELetRec(var, arg, body, rest) ->
let rec new_vars = (var, VClosure(arg, new_vars, body)) ::
vars in
eval new_vars rest
If I define eval like this, it will still correctly evaluate your
fibonacci example, but it will no longer loop infinitely on an
example like "let foo x = x + 1 in let bar y = (foo y) + 1 in bar 3".
Regards,
Bruno
--
Bruno De Fraine
Vrije Universiteit Brussel
Faculty of Applied Sciences, INFO - SSEL
Room 4K208, Pleinlaan 2, B-1050 Brussels
tel: +32 (0)2 629 29 75
fax: +32 (0)2 629 28 70
e-mail: Bruno.De.Fraine@vub.ac.be
next prev parent reply other threads:[~2007-04-03 13:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-02 23:55 Brian Hurt
2007-04-03 6:24 ` Gleb Alexeyev
2007-04-03 6:58 ` [Caml-list] " Ville-Pertti Keinonen
2007-04-03 7:00 ` Andrej Bauer
2007-04-03 12:09 ` Jon Harrop
2007-04-03 13:31 ` Bruno De Fraine [this message]
2007-04-04 23:28 ` Brian Hurt
2007-04-05 0:51 ` Jon Harrop
2007-04-03 12:49 ` Philippe Wang
2007-04-04 3:52 ` Stefan Monnier
2007-04-04 5:28 ` [Caml-list] " skaller
2007-10-04 17:48 ` Fabrice Marchant
2007-10-04 20:39 ` skaller
2007-10-04 21:36 ` rossberg
2007-10-04 22:25 ` skaller
2007-10-05 10:42 ` Dominique Martinet
2007-10-08 9:57 ` Andreas Rossberg
2007-04-04 8:45 ` Don Syme
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=2F51D421-AFAD-42F4-8DE5-E6416EC03CAB@vub.ac.be \
--to=bruno.de.fraine@vub.ac.be \
--cc=caml-list@inria.fr \
--cc=jon@ffconsultancy.com \
/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