Java: Helping the world build bigger idiots
Greg Black
cryptography at mail.gbch.net
Tue Sep 20 20:38:41 EDT 2005
On 2005-09-20, Jerrold Leichter wrote:
> One thing to consider is that an idiom like this solves an annoying problem.
> Consider a linear search through an array:
>
> for (i = 0; i < lim; i++)
> { if (a[i] == target)
> { <do something>
> break;
> }
> }
> /*
> * Did we get here because we matched or because we
> * failed to match?
> */
No, we got here because we didn't know basic C usage. Come on
people, please stop creating these fake illustrations.
A real C programmer would have known that, if i == lim, there
was no match. This is so trivial it beggars belief that it
needs to be pointed out in a forum like this.
> Personally, I sometimes use:
>
> for (i = 0; i < lim; i++)
> { if (a[i] == target)
> goto found;
> }
>
> This draws shock and horror from some code readers, but I don't care. :-)
> Note how much it looks like the exception-based code.
It only draws gasps from people who don't know C. The goto that
is famously considered harmful is not spelled "goto" in C, but
rather "longjmp"; it's not used all that often and does need
careful handling. The C goto statement is purely a local goto
and scares nobody who has grown up.
Greg
---------------------------------------------------------------------
The Cryptography Mailing List
Unsubscribe by sending "unsubscribe cryptography" to majordomo at metzdowd.com
More information about the cryptography
mailing list