Comment #0 by andrej.mitrovich — 2014-05-06T19:22:40Z
-----
import std.ascii;
import std.algorithm;
import std.stdio;
void main()
{
writeln( "foo-bar-doo".map!(a => a.isAlphaNum ? a : '_') );
writeln( "foo-bar-doo".map!(a => a.isAlphaNum ? a : cast(dchar)'_') );
}
-----
$ dmd -run test.d
> [102, 111, 111, 95, 98, 97, 114, 95, 100, 111, 111]
> foo_bar_doo
This is very ugly. I'm not sure whether it's a DMD bug or a Phobos bug though.
Comment #1 by bearophile_hugs — 2014-05-06T19:52:03Z
(In reply to Andrej Mitrovic from comment #0)
> This is very ugly. I'm not sure whether it's a DMD bug or a Phobos bug
> though.
It's an ugly dmd bug:
void main() {
pragma(msg, typeof(true ? char('x') : '_'));
pragma(msg, typeof(true ? wchar('x') : '_'));
pragma(msg, typeof(true ? dchar('x') : '_'));
}
Output:
char
int
uint
But perhaps I already reported this issue, please search it in Bugzilla.
Comment #2 by andrej.mitrovich — 2014-05-06T20:57:54Z