http://d.puremagic.com/issues/show_bug.cgi?id=10999
--- Comment #7 from [email protected] 2013-09-11 14:02:28 PDT --- (In reply to comment #5) > Please elaborate on which kind of > type safety is broken by conversion from short to ushort (please with examples > of system languages like C/C++). "Type safety" is related to "strong typing". Strong typing means the compiler refuses to use a type (like ushort) where you have specified another type (like short), unless you also have explicitly specified what other types are accepted (this for structural typing, subtyping, etc). And I don't care of C/C++, thankfully D is not one of those two languages. > (different ranges is not a problem because it > is the same data reinterpreted in differen ways - which is not a surprise in > low-level languages) It's a problem because they are seen as potentially different values, so the semantic of your program could change. > This can't be an argument as similar situation can be created with other > conversions in D. In other words, if you consider your example as an argument > against implicit conversion, following should also be disallowed: > > import std.stdio; > > void bar(bool) { "bool".writeln; } > void bar(long) { "long".writeln; } > void main() { > int a; > bar(a); // long > bar(1); // bool > bar(2); // long > } > > import std.stdio; > > void bar(int[]) { "int[]".writeln; } > void bar(int[1]) { "int[1]".writeln; } > void main() { > int[1] a; > bar(a); // int[1] > bar([1]); // int[1] > bar([]); // int[] > bar([1,1]); //int[] > } > > and some other conversion stuff. There are indeed discussions about changing the semantics of booleans a little in D, to refuse some dangerous implicit conversions. Recently there was a long thread about this in the main D newsgroup. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
