www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - example code fails, std.stream

I have this little program:

import std.stdio;
import std.stream;


void main ()
{
Stream file = new BufferedFile("spec.txt");
 foreach(ulong n, string line; file) {
stdout.writefln("line %d: %s",n,line);
 }
file.close();
}

which is basicall a cut-n-paste from
http://digitalmars.com/d/2.0/phobos/std_stream.html
which fails with:
solvejk.d(8): Error: function std.stream.Stream.opApply (scope int
delegate(ref char[]) dg) is not callable using argument types (int
delegate(ref ulong __apply
Arg0, ref string __applyArg1))
solvejk.d(8): Error: cannot implicitly convert expression (__foreachbody765)
of type int delegate(ref ulong __applyArg0, ref string __applyArg1) to int
delegate
(ref ulong n, ref wchar[] line)


This is on windows and dmd is Digital Mars D Compiler v2.050
downloded from http://ftp.digitalmars.com/dmd.2.050.zip (link from dmd
annonce list)

where to go?
Nov 06 2010