I'm having some problems trying to get the best of both worlds here.
void f(Class c) {
assert(c != null);
// use c
}
In this example, we tell the compiler that c is never able to be null.
The compiler can use assertions like this for optimizations (not sure if
dmd does this though).
But
Jonathan M Davis wrote:
On 2011-05-30 12:49, simendsjo wrote:
I'm having some problems trying to get the best of both worlds here.
void f(Class c) {
assert(c != null);
// use c
}
In this example, we tell the compiler that c is never able to be null.
The compiler can use assertions
On 2011-05-30 14:39, Timon Gehr wrote:
Jonathan M Davis wrote:
On 2011-05-30 12:49, simendsjo wrote:
I'm having some problems trying to get the best of both worlds here.
void f(Class c) {
assert(c != null);
// use c
}
In this example, we tell the compiler that c is
Timon Gehr:
The answer is yes, theoretically it could. (It would either have to have some
very
advanced code analysis caps, or would just have to treat enforce specially.)
Id's not so advanced stuff.
Bye,
bearophile
On 5/30/2011 2:55 PM, Jonathan M Davis wrote:
I'd be very surprised to see the compiler ever optimize code based on assert
or enforce statement. It's unlikely to do so based on assert simply because
the assertion is going to be compiled out. I think that there's a high chance
that
On 2011-05-30 15:03, Brad Roberts wrote:
On 5/30/2011 2:55 PM, Jonathan M Davis wrote:
I'd be very surprised to see the compiler ever optimize code based on
assert or enforce statement. It's unlikely to do so based on assert
simply because the assertion is going to be compiled out. I think
Timon Gehr:
The answer is yes, theoretically it could. (It would either have to have
some very
advanced code analysis caps, or would just have to treat enforce specially.)
Id's not so advanced stuff.
Bye,
bearophile
You are saying that analyzing a function for thrown exceptions and