DISQUS

DISQUS Hello!  The comments on this profile are unclaimed and thus are unverified.

Do they belong to you? Claim these comments.

Keithb's picture

Unregistered

Feeds

aliases

  • Keithb

Keithb

3 years ago

in Three Lefts Make a Right: The Type Declaration Paradox on Languages of the real and artificial
Colour me baffled (does that make me one of the smart people?)

Of the approaches you present exactly one will definitely prevent the function body being executedwith ill-typed arguments by any client code: assertions.

Variable names, comments and structured comments will not provent client code asking for gcd(-7.62, 2+i), but they will prompt any human who's read the declaration of gcd to not casually write code that would do that, which seems like a win. This is the way programmers in languages with dynamic typing get used to thinking.

Of your proposed aproaches exactly one tells the human programmer and the client code a direct lie about gcd(): type declaration. It does not merely "[lose] the information that a and b are non-negative", it asserts the untruth that they can be negative. How is this any sort of benefit?
Returning? Login