From: "David A. Black" Date: 2004-09-17T03:20:05+09:00 Subject: Re: Ex-Perl coders: Howz it feel to convert to Ruby? Hi -- On Fri, 17 Sep 2004, Phil Tomson wrote: > In article , > David A. Black wrote: > >Hi -- > > > >On Thu, 16 Sep 2004, ChrisO wrote: > >> > >> Yes, this is a better example of what I was talking about, and yes, you > >> can provide better indication here in Ruby than in Perl, I have to > >> admit. So, to see the parallels, I'll bet you see a lot more of the > >> simple yields in block handling method definitions in classes than you > >> do in the form of you second example with the spiked out parameter and > >> the param.call approach. It's disciplined, well constructed code, but > >> not everyone is like that. Hence the Perl dilemma/diatribe here. > > > >There's nothing wrong with doing this the way Phil has, but there's > >also nothing wrong or undisciplined about using yield. Let's not > >stigmatize people who use yield (for example, Matz and many of the > >other authors of the Ruby standard library) as undisciplined. It's > >not a test of character; it's a programming idiom. You can work > >around it if you don't like it, as Phil has shown, or you can use it, > >as others have shown, in the course of writing perfectly good and > >clear code. > > > > >When you supply a block to a method, you need to know how the block is > >going to be called -- which means you'll probably either have written > >the method yourself, or consulted some documentation that explains how > >the method works. So in practical terms, the use of yield vs. calling > >the block explicitly probably doesn't matter too much too often. You > >can use whichever semantics you like. > > > > > > I agree totally. I did not intend to stigmatize people for using 'yield'. > In fact, I tend to use 'yield' as often as the alternative. I think I > sometimes prefer yield because even though it tends to make the arguments > to the method somewhat ambiguous, the intent can sometimes seem clearer in > the body of the method (vs the 'call'). I was referring mainly to Chris's characterization of yield users as different from people who write disciplined, well-constructed code. I suspect that Chris didn't really mean it as a slam to yield users either, but it kind of read that way. (And I'm at least a frequent yield user myself :-) David -- David A. Black dblack@wobblini.net