== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article > On Wed, 12 Oct 2011 09:46:57 -0400, Trass3r <u...@known.com> wrote: > >> I believe that the primary reasoning for allowing the implicit > >> conversion > >> between int and dchar is so that code like this > >> > >> dchar c = 'a' + 7; > > > > That's a '+' though, not a '~'. > Jonathan meant this better example ;) > string s = "hello"; > s ~= 'a' + 7;
It's still fine if '~' does not allow implicit casting but '+' does. 'a' + 7 -> 'h' which is already a dchar. So it can be appended to s without casting. Now the question is how easy it is to allow implicit casting for some operators but not other operators. > > I think it shouldn't be allowed with ~ since it's misleading. > > Newbies would probably expect "abc" ~ 10 to yield "abc10" rather than > > the odd "abc\n". > 100% agree. Requiring a cast in order to convert to dchar is a small > price to pay (not that common to do arithmetic with characters) for > avoiding surprising compilations. > -Steve