Jump to content

Talk:Postcondition

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Brian Geppert (talk | contribs) at 15:44, 24 May 2011 (Replying to the idea that "result must be an integer" is uneccessary.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

WikiProject iconComputing Unassessed
WikiProject iconThis article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
???This article has not yet received a rating on Wikipedia's content assessment scale.
???This article has not yet received a rating on the project's importance scale.

Would it make sense to merge postcondition and precondition? --Abdull 13:00, 2 August 2006 (UTC)[reply]

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)[reply]
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)[reply]

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)[reply]