[nem-bug] [Nemerle 0000606]: possible problem with loop closures

feedback at nemerle.org feedback at nemerle.org
Mon May 22 18:03:36 CEST 2006


The following issue has been CLOSED
======================================================================
<http://nemerle.org/bugs/view.php?id=606> 
======================================================================
Reported By:                malekith
Assigned To:                malekith
======================================================================
Project:                    Nemerle
Issue ID:                   606
Category:                   Compiler
Reproducibility:            always
Severity:                   major
Priority:                   high
Status:                     closed
Resolution:                 fixed
Fixed in Version:           
======================================================================
Date Submitted:             01-29-2006 09:22 CET
Last Modified:              05-22-2006 18:03 CEST
======================================================================
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 = ()
#

----------------------------------------------------------------------
 malekith - 03-13-06 08:31 
----------------------------------------------------------------------
Fixed in r6158.

Issue History
Date Modified  Username       Field                    Change              
======================================================================
01-29-06 09:22 malekith       New Issue                                    
01-29-06 09:29 malekith       Note Added: 0001064                          
03-13-06 08:31 malekith       Status                   new => resolved     
03-13-06 08:31 malekith       Resolution               open => fixed       
03-13-06 08:31 malekith       Assigned To               => malekith        
03-13-06 08:31 malekith       Note Added: 0001122                          
03-13-06 08:31 malekith       Description Updated                          
05-22-06 18:03 nazgul         Status                   resolved => closed  
======================================================================




More information about the bugs mailing list