Re: Implicit type conversions with data loss

2012-06-07 Thread renoX
On Thursday, 7 June 2012 at 03:19:18 UTC, ctrl wrote: Thanks for your answers. You want a sane language: use a different language, most C-derived language have insane semantic for integers.. Have you tried Ada? I want a language with metaprogramming and compile-time computations. A google

Re: Implicit type conversions with data loss

2012-06-06 Thread renoX
On Tuesday, 5 June 2012 at 18:06:15 UTC, ctrl wrote: I don't want them to be performed at all. How do I disable this 'feature'? For example, take a look at this code: import std.stdio; void main() { int x = -1; uint b = x; writeln(b); } It outputs 4294967295, but I wan

Re: Implicit type conversions with data loss

2012-06-05 Thread Jonathan M Davis
On Wednesday, June 06, 2012 10:07:04 Dmitry Olshansky wrote: > On 05.06.2012 22:06, ctrl wrote: > > I don't want them to be performed at all. How do I disable this 'feature'? > > > > For example, take a look at this code: > > > > import std.stdio; > > void main() { > > int x = -1; > > uint b = x;

Re: Implicit type conversions with data loss

2012-06-05 Thread Dmitry Olshansky
On 05.06.2012 22:06, ctrl wrote: I don't want them to be performed at all. How do I disable this 'feature'? For example, take a look at this code: import std.stdio; void main() { int x = -1; uint b = x; writeln(b); } It outputs 4294967295, but I want a compile-time error instead. Any suggestio

Re: Implicit type conversions with data loss

2012-06-05 Thread Thiez
On Tuesday, 5 June 2012 at 22:17:57 UTC, bearophile wrote: Or you can add an assert/enforce, or you can create a small struct that represent safely assignable uints, etc. No solution is good. Bye, bearophile Surely structs could work? struct safeType(T) { T value; } Define all operatio

Re: Implicit type conversions with data loss

2012-06-05 Thread bearophile
Languages as Ada, Delphi, C# and few others (C/C++ too, with a new Clang feature) know that overflow of fixnums is a very common source of bad bugs, so they offer optional run-time tests to assignments and numerical operations. D too will eventually need those. A little example of the difficu

Re: Implicit type conversions with data loss

2012-06-05 Thread bearophile
ctrl: I don't want them to be performed at all. How do I disable this 'feature'? For example, take a look at this code: import std.stdio; void main() { int x = -1; uint b = x; writeln(b); } It outputs 4294967295, but I want a compile-time error instead. Any suggestio

Re: Implicit type conversions with data loss

2012-06-05 Thread Paul D. Anderson
On Tuesday, 5 June 2012 at 18:06:15 UTC, ctrl wrote: I don't want them to be performed at all. How do I disable this 'feature'? For example, take a look at this code: import std.stdio; void main() { int x = -1; uint b = x; writeln(b); } It outputs 4294967295, but I wan

Implicit type conversions with data loss

2012-06-05 Thread ctrl
I don't want them to be performed at all. How do I disable this 'feature'? For example, take a look at this code: import std.stdio; void main() { int x = -1; uint b = x; writeln(b); } It outputs 4294967295, but I want a compile-time error instead. Any suggestions? (co