sc.ini and delegates

TheFlyingFiddle kurtyan at student.chalmers.se
Mon Feb 24 16:04:42 PST 2014


On Monday, 24 February 2014 at 20:54:55 UTC, Eugene Yang wrote:
> Hello all,
>
> If I want to set custom imports and library search paths for a 
> specific project, how do I specify those paths in the sc.ini 
> file?  Setting the DFLAGS environment variable seems to 
> override the default settings; is there a way I can append to 
> the default DFLAGS variable?
>
> Also, if I try to compile this code
>
> import std.stdio, std.algorithm;
>
> char toInverse(in char input)
> {
> 	if(input == 'a')
> 		return 'b';
> 	return 'c';
> }
>
> void main(string[] args)
> {
> 	string line = readln();
> 	auto result = line.map!(toInverse);
> 	writeln(result);
> }
>
> I get an error saying that toInverse is not callable with the 
> argument type dchar.  Why is line, which should be 
> immutable(char)[] being casted as a dchar array?
>
> Thanks in advance,
> Eugene Yang

The array itself is not casted to a dchar array, but when 
iterating over a string using range interfaces (eg map!(...) in 
your code) it will do the iteration over dchars instead of char. 
This is to make it simpler to write correct unicode processing 
code. How this is done is simply that the string.front property 
has the type dchar and whenever you access it some unicode 
processing will be done.

This is quite counter intuitive the first time you run into it. 
See 
http://forum.dlang.org/thread/urhhmrnzovxnyufcipwt@forum.dlang.org#post-mailman.384.1389668512.15871.digitalmars-d-learn:40puremagic.com 
for a more indepth view on why and how string iteration is 
implemented in this way.








More information about the Digitalmars-d mailing list