3 ms·
And with a glance at the call stack you'll know which method supplied that so called pig in the first place. For me seeing something like: doSomething(Pig
by mattmanser 15y ago
And with a glance at the call stack you'll know which method supplied that so called pig in the first place.
For me seeing something like:
doSomething(Pig pig)
previousThing(Mammal mammal)
firstThing()
Main()
It's pretty obvious where the pig came from. Even if the names were less helpful than Pig and Mammal a quick scan through the methods would take you there quick, my IDE at least has a tool to jump to variable declarations.
Getting to the bottom of where that bug originated is trivial.
- pwpwp 15y agoThe ill-typed value could come from anywhere in the program.
- sausagefeet 15y agopwpwp's example is just the trivial case, the point is the change happens outside the usage callstack. Structural typing can fit a lot of the issues your parent post raised as well. Simply type check on what the function using the value cares about, not that it belongs to same name.