Re: [Pharo-users] type checking in Smalltalk
2017-03-30 16:03 GMT+02:00 Marc Hanisch via Pharo-users < pharo-users@lists.pharo.org>:
It is advised not to use the message isKindOf: in applications.
I do understand that it is not a good idea to do different operations depending on the kind of an object in one method. But in my (Javascript) production code I do a lot of checking if an argument to a function is "instanceof" someObject. When it is not the expected type of object, an exception is thrown. I do this to ensure that someone (=another developer) does not by accident passes a wrong type into my method.
Reading this, I realized, that I never saw such type-checking in Pharo production code.
In Pharo you will got DNU error automatically when object will receive message which it *d*oes *n*ot *u*nderstands. Then Pharo will show debugger to investigate and fix the problem. This is called dynamic typing and I guess JS will do something similar. So I wonder why you need custom error when program breaks types.
participants (1)
-
Denis Kudriashov