[nem-bug] [Nemerle 0000606]: possible problem with loop closures
feedback at nemerle.org
feedback at nemerle.org
Sun Jan 29 09:29:11 CET 2006
A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=606>
======================================================================
Reported By: malekith
Assigned To:
======================================================================
Project: Nemerle
Issue ID: 606
Category: Compiler
Reproducibility: always
Severity: major
Priority: high
Status: new
======================================================================
Date Submitted: 01-29-2006 09:22 CET
Last Modified: 01-29-2006 09:29 CET
======================================================================
Summary: possible problem with loop closures
Description:
it prints 3 3 3, instead of 1 2 3.
using Nemerle.Collections
def d = Queue ()
foreach (x in [1..3])
d.Push (fun () { System.Console.WriteLine (x) })
while (!d.IsEmpty)
d.Take () ()
======================================================================
----------------------------------------------------------------------
malekith - 01-29-06 09:29
----------------------------------------------------------------------
OCaml:
# let q = ref [] ;;
val q : '_a list ref = {contents = []}
# for n =1 to 3 do q := (fun()->print_int n) :: !q; done;;
- : unit = ()
# List.iter (fun f -> f ()) (!q);;
321- : unit = ()
#
Issue History
Date Modified Username Field Change
======================================================================
01-29-06 09:22 malekith New Issue
01-29-06 09:29 malekith Note Added: 0001064
======================================================================
More information about the bugs
mailing list