From: Jack Dempsey Date: 2002-01-16T01:44:46+09:00 Subject: RE: benefits of callbacks Ok...the idea made sense before, but I can see how this would really save some time in certain situations. Thanks! Jack > -----Original Message----- > From: Sean Middleditch [mailto:elanthis@awesomeplay.com] > Sent: Tuesday, January 15, 2002 11:43 AM > To: ruby-talk ML > Subject: RE: benefits of callbacks > > > Signals. You can register a function (or an object, in Ruby) to listen > to a particular function in another object. Then, when said signal is > generated, the callback is activated. > > The place this is most commonly used is a GUI. For example, you can > register an object to be called when a user signal is generated (user > clicked on OK button). > > Without callbacks, you'd have to, for ever GUI object, make a child > object with some form of "activate" method or something, which would be > more complex (depending on the exact situation). And then, on top of > that, only the child object could respond - if you need multiple > sections of code to be updated when a signal is generated, it wouldn't > be possible without callbacks (or some really really ugly code). > > Another way to look at callbacks is the way Ruby allows you to > dynamically change a method in an object. This is, really, just another > form of callbacks. Setting the method is analogous to registering a > callback; when the object invokes the method, it's just like calling a > callback. Of course, setting a method of an object is limited in that > you can only have *one* callback registered for a particular purpose at > a time... > > On Tue, 2002-01-15 at 11:31, Jack Dempsey wrote: > > Ok, but being in Ruby (which most certainly is OO =P), why are > callbacks so > > useful? > > > > Thanks! > > Jack > > > > > -----Original Message----- > > > From: Ralph Mason [mailto:ralph.mason@telogis.com] > > > Sent: Tuesday, January 15, 2002 2:47 AM > > > To: ruby-talk ML > > > Subject: Re: benefits of callbacks > > > > > > > > > A callback gives the power of a virtual or late binding function > > > to a non OO > > > language. > > > > > > Will that do? > > > > > > Ralph > > > > > > ----- Original Message ----- > > > From: "Jack Dempsey" > > > To: "ruby-talk ML" > > > Sent: Tuesday, January 15, 2002 8:10 PM > > > Subject: benefits of callbacks > > > > > > > > > > A co-worker asked today what they were and why they are so > > > useful, and to > > > be > > > > honest, I struggled in giving a good example. Anyone have a sec > > > to spare? > > > > > > > > Thanks! > > > > Jack > > > > > > > > > > > > > > > > > > >