counter++ versus "add 1 to counter"

A.C.T. albrecht at act-net.com
Sun Mar 21 10:45:00 EST 2004


Hi, Ken,

> You say "add 1 to counter" - a lot clearer than "counter++", IMHO.

Thanks a lot for the hint.

Actually, it's not clearer: One of the first programming languages I 
learned was Machine Language (not Assembler but the hex codes needed to 
make something happen). There were codes that did "incremet" the content 
of a register - which is exactly what "counter++" does: Increment a 
value (by one). That's clear and there's no doubt about what is meant.
"add 1 to counter" is not clear since it is "human language". Does it 
mean "increment the value of counter by 1" or does it mean "add another 
counter to the counter I already have" (meaning: I have two counters 
now)? Add 1 WHAT to counter - 1 banana or 1 bit? Consider "counter" to 
be a pointer instead of a variable, so adding 1 to it leads to a 
completely different result - as this example may show:

"counter" is a pointer to "12345".
printf("%s",counter) will output "12345" - just as expected.
Adding 1 to counter and printf-ing counter again will output "2345" now, 
which is not the same as incrementing the _value_ of counter (type 
casted to int).

To sum it up: I understand "Transcript" is trying to be a chimere of 
"human language" (which uses redundancy to gain clearness) and 
"progamming language" (which avoids redundancy to gain clearness). The 
drawback is that you (the developer) have to EXACTLY now what the 
language (Transcript) will do if you tell it something, whereas a 
"classic" high level language like C will ONLY do what you tell it, 
returning an error if you did not use the right variable type.

Marc Albrecht
A.C.T. / Level-2
Glinder Str. 2
27432 Ebersdorf
Deutschland
Tel. (+49) (0)4765-830060
Fax. (+49) (0)4765-830064


More information about the use-livecode mailing list