"Juha Pohjalainen" <voidjump / nic.fi> wrote in message news:20010530083405.C15296 / lanfear.nic.fi... > 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. No matter how you name it, I don't think it states your intention intuitively, because you have to interpret the block - in other words you have to understand the convention pretty thoroughly to get it, just like you would have to understand the C-convention, which I agree sucks but POLS tells me to stick with an existing convention rather than introduce a new one unless it offers significant benefits. The advantage of the C-convention over yours is that you can at least see it and analyze it in one place. If revealing intention is your real goal, then I think the long version with intention revealing variable names is preferable to what you are proposing - especially because the code is right in front of you. > I think it is more efficient, because no need for temporary variable. tryturn( scientists ) {|x| return x} in your example creates a temporary variable in the block. It also generates another method call and potentially a yield to a block. Anyway, your code is interesting enough to keep me thinking about it for awhile - would like to see your thoughts on additional power of this technique. Wayne