On Thu, Feb 27, 2014 at 12:16:21AM +0000, Jakob Ovrum wrote: > On Thursday, 27 February 2014 at 00:07:47 UTC, H. S. Teoh wrote: > >On Wed, Feb 26, 2014 at 11:59:07PM +0000, bearophile wrote: > >>H. S. Teoh: > >> > >>>I'm writing a CLI program that uses File.ByLine to read input > >>>commands, > >> > >>Isn't using readln() better for that? File.byLine is to read lines > >>of files on disk. > >[...] > > > >Perhaps, but readln() isn't a range. The whole point was to use a > >range-based API for the interpreter so that there's no need to write > >two separate interfaces for the interpreter, one for stdin, one for a > >script file stored on disk. > > > > > >T > > Just write a function that accepts a std.stdio.File parameter?
Unfortunately, I use string arrays in my unittests (to avoid having to create separate unittest input files). So passing in File wouldn't work. Besides, File isn't a range, so that kinda defeats the purpose (my current hack of lazily constructing ByLine does work). I just find it unfortunate that such hacks are necessary to get off the ground. T -- It won't be covered in the book. The source code has to be useful for something, after all. -- Larry Wall
