Component Programming example

Justin Whear justin at economicmodeling.com
Fri Aug 2 10:03:44 PDT 2013


On Fri, 02 Aug 2013 18:59:12 +0200, Jonathan A Dunlap wrote:

> The example:
> http://www.drdobbs.com/architecture-and-design/component-programming-in-
d/240008321?pgno=4
> 
> import std.stdio;
> import std.array;
> import std.algorithm;
> 
>      void main() {
>          stdin.byLine(KeepTerminator.yes)    // 1 map!(a => a.idup).    
>                       // 2 array.                              // 3
>          sort.                               // 4 copy(                 
>                       // 5
>              stdout.lockingTextWriter());    // 6
>      }
> 
> I don't understand what happens to the output. On windows, I can keep
> entering lines but no output gets displayed. Also, can someone explain a
> bit more about lockingTextWriter?
> 
> Thanks!

1) The example has a typo; there should be a '.' between the byLine call 
and the array call.

2) The example collects all input before writing anything (so that it can 
sort).  Hit your end-of-file character (Ctrl-D) for me to end the input.  
Or direct a file into the process' stdin (not sure how to do this on 
Windows, it's been so long).


More information about the Digitalmars-d-learn mailing list