build / design time errors?

  • Thread starter Thread starter Nick Stansbury
  • Start date Start date
N

Nick Stansbury

Hi,

Is there any way to control the raising of "build" errors? For example -
is there any possible way of, for example, raising a build error if the
object user tries to call method(x) before having set property y ?

Thanks
 
Nick Stansbury said:
Hi,

Is there any way to control the raising of "build" errors? For
example -
is there any possible way of, for example, raising a build error if the
object user tries to call method(x) before having set property y ?

What do you mean "before"? How could the compiler determine what the runtime
sequence of events would be?

This is the sort of thing you have to do at runtime.

John Saunders
 
The compiler can detect code that cannot be reached, and throws warnings
about that; how, particularly, is "require-x-before-y" really any different?

Conceptually, these seem like very similar concepts, and I don't see why the
compiler mechanisms that do dead-code detection could not be adapted for
this purpose as well. Is it just that nobody has bothered to teach the
compiler that particular trick, or is there something more subtle I'm not
seeing?
 
Marcos Stefanakopolus said:
The compiler can detect code that cannot be reached, and throws warnings
about that; how, particularly, is "require-x-before-y" really any
different?

Conceptually, these seem like very similar concepts, and I don't see why
the compiler mechanisms that do dead-code detection could not be adapted
for this purpose as well. Is it just that nobody has bothered to teach
the compiler that particular trick, or is there something more subtle I'm
not seeing?


The compiler knows the code paths within a method and can determine that a
piece of code might not be reached. But if you're talking about a publicly
accessible property, the compiler has no way to determine what piece of code
might ultimately set that property. It might be set by code which is not
even in the same compilation.

John Saunders
 
Back
Top