Well, I'm not sure whether it's called Hungarian notation or not, but in BASIC for example, a string variable name is prefixed with a $ character, integers start with % and floating point numbers have no prefix.
That way, you can have 3 different variables called $x, %x and x and know what type of value they can contain (even though "x" tells you little else).
Trying to give a value in the wrong format, such as adding 0.5 to an integer, would cause a "type mismatch" error.
Okay, so maybe that restriction does force you to do unecessary conversions at times, but those prefixes do make it easier to debug unfamiliar code.
It also makes it more obvious what type of value a particular subroutine is expecting to have passed to it if you want to reuse it elsewhere.
I'm sure I can find some way to make it clearer what type of value my variables are intended to be used with. I was just hoping there was some way to have that checked every once in a while during development.
There have been plenty of good suggestions given to help anyway. :o)
|