On Wed, May 30, 2001 at 07:41:25AM +0900, Wayne Blair wrote:
> I always had a love/hate relationship with the efficient but cryptic:
> 
> if (x=getValue) return x

More recently my love/hate relationship with such code has turned
to be hate/hate relationship. :-(

First, I don't like using too short and meaningless variable names.
Secondly, above code opens up possibility for errors like:
	if (x==getValue) return x

	That is, if you come later back to that code (or someone
	else comes back) one year later, and have to change something,
	meaning of original code might have been forgotten and cryptic
	code does not help.

> I like the idea of creating something less cryptic and just as efficient,
> but your implementation doesn't seem to make it less cryptic or more
> efficient.

I think it is less cryptic, because it states your intention. (And
if someone comes up with better english word for it, then more it
states the intention of code and not side effects; my native
language is finnish, so coming up with english words is not my
strongest point.)

I think it is more efficient, because no need for temporary variable.

> Here is the traditional way of doing it:
> 
>  | def doSomethingWith value
>  |   if (result = tryFirstThing value) then return result
>  |   makeSomePreparations value
>  |   if (result = trySomethingElse value) then return result
>  |   raise TypeError, "could not do it"
>  | end
> 

Traditional way of doing things is not always the right way. Or
we could still be using punchcards (or no computers at all in
our caves).

> Wayne

"Have a great day", says Jippo

-- 
 __________________________________________________________________
[   pub 1024/951AFAF5 1995/12/12   Juha Pohjalainen <jmp / iki.fi>   ]
[   fingerprint 41 56 7F F9 8E EC 16 35  BB 42 EF A7 DF 19 FA 31   ]
[__ http://www.iki.fi/jmp/ ________________ GSM +358 40 570 1179 __]