example code fails, std.stream

Paul Ingelbrant paul.ingelbrant at gmail.com
Sat Nov 6 06:53:35 PDT 2010


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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20101106/0d578bb2/attachment.html>


More information about the Digitalmars-d-learn mailing list