checkedTo

Martin Nowak dawg at dawgfoto.de
Thu Nov 3 10:59:59 PDT 2011


On Thu, 03 Nov 2011 16:54:14 +0100, Jonathan M Davis <jmdavisProg at gmx.com>  
wrote:

> On Thursday, November 03, 2011 13:38:44 Gor Gyolchanyan wrote:
>> I think this could be integrated into "to" template without need for
>> extra symbols.
>> There are tons of optimization opportunities like this, that are
>> currently not being utilized.
>> If the result won't change, then the release version should drop safety
>> checks.
>
No way, it does unsafe conversions to safe quite some cycles.
You have no way of guaranteeing correct output for to! without doing the  
check.

> And how would std.conv.to know that the result won't change? It k
> nows nothing about the variable it's being passed, and that variable  
> could
> depend on user input or what's in a file or some other value which is  
> runtime-
> dependent.
>
> I don't believe that anything in Phobos changes behavior based on -debug
> (there are a few places where -debug=something results in a module  
> printing
> extra stuff for unittests - e.g. -debug=string for std.string - but not  
> for -
> debug), and -debug is really meant for debugging purposes, not for  
> enabling or
> disabling checks. That's for -release, which, for better or worse, you  
> can't
> actually check for in code. So, really, there is no way to have -release  
> affect
I guess one would make it an assertion in phobos code.

> any code in Phobos beyond what it does to the language in general (remove
> assertions and remove array bounds checking in @system code), even if we
> wanted it to, which is debatable.
>
> - Jonathan M Davis


More information about the Digitalmars-d mailing list