Tag Info

New answers tagged

0

A good example for this comes from code I have seen recently: if foo bar == baz # should be bar = baz In python expressions like this work totally fine but they don't do what you intended. Another typo in the same code: class foo: ... def bar(self): ... def foo_bar: ... ... foo.bar() # They meant to use foo_bar() Sure ...


3

Unit tests don't actively prevent type errors, but they do provide you a mechanism to execute the code you have written before the entire application is complete. If you try to do something silly, like mistyping calculateInterest as claculateinterest, then that will be caught early on if you use a statically typed, compiled language like Java because the ...


3

Single method interfaces and functions (or functions type definitions) are almost the same. Function type definitions are just anonymous interfaces. Interfaces and function type definitions both serve the same purpose. And together with their implementation they could be described as mathematical duals. An object (or in this case a single method interface ...


1

Conceptually, are single method interface and type definition on functions the same thing? No. In most languages that allow both, the function typedef defines a type whose values are functions and nothing else. The abstract class defines an interface which has a function (and likely, other things). Things can get muddled with closures (which are ...


0

Is it possible to implement, for example, locking with unique types? I followed the link that Robert Harvey provided and I did a quick read-up. I cannot say that I understood everything or that I have a high level of confidence that I really understood what I think I understood, but it appears to me that the whole point of external uniqueness and ...



Top 50 recent answers are included