problems with DPL example.

simendsjo simendsjo at gmail.com
Mon Oct 10 10:59:34 PDT 2011


On 10.10.2011 19:55, %u wrote:
> Hello.  I'm having problems compiling the following:
>
> // From chapter 1 of D Programming Language.
> //
> import std.stdio, std.string;
>
> void main() {
>    uint[string] dictionary;
>
>    foreach( line; stdin.byLine()) {
>      // Break sentence into words
>      // Add each word in the sentence to the vocabulary
>      foreach( word; splitter(strip(line))) {
>        if( word in dictionary) continue; // Nothing to do.
>        auto newID = dictionary.length;
>        dictionary[word] = newID;
>        writeln( newid, '\t', word);
>      }
>    }
>    return;
> }
>
>
>
> $ dmd wordcount.d
> wordcount.d(9): Error: undefined identifier splitter
>
>
>
> $ dmd -v
> DMD32 D Compiler v2.055
> Copyright (c) 1999-2011 by Digital Mars written by Walter Bright
> Documentation: http://www.digitalmars.com/d/2.0/index.html
>
>
> I am doing the examples in cygwin.
>
> Anyone know what the problem is?
>
>
> thanks.
>
>

Seems some functionality was moved in 2.052. From std.string documentation:
"IMPORTANT NOTE: Beginning with version 2.052, the following symbols 
have been generalized beyond strings and moved to different modules."
And
"split	Use std.array.split instead"

std.array includes both split and splitter.
http://www.d-programming-language.org/phobos/std_array.html#split


More information about the Digitalmars-d-learn mailing list