*I just invented this on the spot as an example.
On the subject of languages. things I would like to see in language X
override void mymethodthing( int x | ( x > 0 :"no negative array arguments ") | , Object o | o != null && o.valid() )
{
//being method
}
this would mean that when someone called this method like this
thing. mymethodthing( -3 , this ) ;
// this is the calling line. that is the line | ( x > 0 :"no negative array arguments ") | is an assert sayign the first integer argument is non negative.
there would be a COMPILE TIME error or a RUNTIME error on the calling line ( not the sub routine ). After all the subroutine interface clearly states the limits of the method/function and you have just crossed the line. the problem is with the calling code not the method ( which has clearly stated the assumtions). May be more asserts could be used to augment code generation. More programming concepts later.
No comments:
Post a Comment