problems with DPL example.
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.
Re: problems with DPL example.
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
Re: problems with DPL example.
You need to create an immutable copy of word before using it as a key. That is, replace this line: dictionary[word] = newID; with dictionary[word.idup] = newID;
Re: problems with DPL example.
%u: Decho hello | wordcount2.exe wordcount2.d 0 hello std.stdio.StdioException@std\stdio.d(2156): Bad file descriptor Try: wordcount2.exe wordcount2.d Bye, bearophile
Re: problems with DPL example.
On 10.10.2011 21:38, bearophile wrote: %u: Decho hello | wordcount2.exe wordcount2.d 0 hello std.stdio.StdioException@std\stdio.d(2156): Bad file descriptor Try: wordcount2.exe wordcount2.d Bye, bearophile Shouldn't the original way work too? Another point: I recommend compiling with debug symbols as it gives you a nice stacktrace.
Re: problems with DPL example.
== Quote from bearophile (bearophileh...@lycos.com)'s article simendsjo: Shouldn't the original way work too? I don't remember. Another point: I recommend compiling with debug symbols as it gives you a nice stacktrace. I think debug symbols should be present on default, to produce a nice stack trace on default, and be disabled with a compiler switch :-) Bye, bearophile If I use file indirection instead of piping output to the d program, it works in cygwin window. I'm not a dos expert, so I don't know how to do the same test on windows. anyways, thanks!
Re: problems with DPL example.
You should checkout out this page: http://erdani.com/tdpl/errata/ - Jonathan M Davis
Re: ref struct?
Andrej Mitrovic: I think this is what refcounted structs are for. ref structs are regular heap-allocated GC-managed structs, but they are managed by reference instead of by pointer. So refcounting is not significant here. -- Jonathan M Davis: That or make it a class and make it final. Such class instances have a 2 words overhead, plus runtime code to initialize those fields. ref structs don't have them. Bye, bearophile
Re: ref struct?
On 10/11/11, bearophile bearophileh...@lycos.com wrote: Andrej Mitrovic: I think this is what refcounted structs are for. ref structs are regular heap-allocated GC-managed structs, but they are managed by reference instead of by pointer. So refcounting is not significant here. But can't you just make a wrapper struct that GC-allocates an internal struct and uses subtyping and refcounting?
indexing php
Every time I press on the D via web browser I get wanna download indexing dot php while D.learn works without problem.