[18537] in cryptography@c2.net mail archive

home help back first fref pref prev next nref lref last post

Re: Java: Helping the world build bigger idiots

daemon@ATHENA.MIT.EDU (Greg Black)
Wed Sep 21 16:18:14 2005

X-Original-To: cryptography@metzdowd.com
X-Original-To: cryptography@metzdowd.com
Date: Wed, 21 Sep 2005 10:38:41 +1000
From: Greg Black <cryptography@mail.gbch.net>
To: cryptography@metzdowd.com
Reply-To: cryptography@metzdowd.com
In-Reply-To: <Pine.SOL.4.61.0509201738470.1340@frame>

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@metzdowd.com

home help back first fref pref prev next nref lref last post