This article is rated Start-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||
|
Would it make sense to merge postcondition and precondition? --Abdull 13:00, 2 August 2006 (UTC)
I think it makes no sense to put "result must be an integer" in the post-condition. It is not dynamically testable by an assertion and the type system will guarantee it anyway. Ian Bayley
- It's a perfectly fine for an example, and might even sense for a weakly typed language which may not have an explicit integer type (like Javascript). Why would it not be dynamically testable? If (result != Integer(result)) then it probably means the result is larger than can be stored as an integer (or alternatively the result is outside the integer bounds of its floating-point representation) and will likely cause problems later on. Good reason to use the postcondition! 198.175.154.212 (talk) 15:59, 29 November 2010 (UTC)
- It is absolutely a necessary postcondition. In a language such as Javascript, I frequently set preconditions/postcondition that the argument/return value satisfy my isNumeric function. In other languages, it's just a coincidence that you can generally interpret as an integer any returned result (because the return result is likely a single word, which is likely the size of the basic integer type, which is likely non-nullable/non-NaN-able). However, even with a statically-typed language this isn't necessarily the case (e.g. if you're using a nullable number type or a not-necessarily-integer type such as floating point). Brian Geppert (talk) 15:44, 24 May 2011 (UTC)
I I think it makes sense to put "result must be an integer" in the post-condition. —Preceding unsigned comment added by 203.196.189.130 (talk) 06:52, 19 May 2011 (UTC)