abuse the type checker

F.S.A.Zuurbier@inter.nl.net F.S.A.Zuurbier@inter.nl.net
Tue, 21 Mar 2000 16:38:26 +0100 (MET)


Dear all

I had a function 'world2seed' that worked on World, and an equivalent one 'io2seed' that worked on IOState, and some more. The functions generated random seeds. I have re-used the functions in many projects. All worked well. So I decided to fix it!

I created a class with a method 'getSeed' and created instances for World, IOState, and some more. But I had no overview of where all the calls to world2seed and io2seed etc. were. As far as I know, the IDE is not able to list them all.

I decided not to hunt them all. But I was sure that whenever I would ever work on any application with a call to world2seed, I would have a hard time understanding the error message 'world2seed undefined' and remembering that I would have to replace the call by 'getSeed'.

Therefore, instead of removing the definition and implementation of word2seed (etc.) altogether, I decided to replace it by:

world2seed :: Replace_world2seed_by_getSeed
world2seed = undef
:: Replace_world2seed_by_getSeed = A

And indeed, a number of times since, I worked on projects where the typechecker told me exactly what to do to fix a problem.

I just felt that I should convey this idea to y'all.

(It is another matter how to decide when to remove this self made error message from the code.)

Greetings
Erik Zuurbier