T. Onoma
11/20/2003 12:58:00 PM
robert:
thanks robert, that's basically what i decided to do. your code is nice and clean to. i like that.
but you know. it strikes me as funny that its thought a good idea to implement nested chains of handlers for errors but not for message passing. it seems like a natural fit to me. but when ever i bring it up i get all sorts of nay nays. what so bad about this idea? i think it would be a very powerful tool. i agree that resume should be automatic for this purpose, and a seperate command should exist. i don't what to hurt the poor little raise command. i'm not that bad! ;)
i may try to implement a way to do it.
later,
-t0
>
> "T. Onoma" <transami@runbox.com> schrieb im Newsbeitrag
> news:E1AMmpA-000682-J5@odie.runbox.com...
> > > You are raising an exception, this is, for me, different than sending
> > > message to stdout
> >
> > okay, i grant you that was not the intention of raise when designed. but
> a rose by any other name....
> >
> > so what other means are there? should a raise_message be added? or maybe
> you are right. maybe my library is "badly designed", but if so then tell
> me what would the alternative be that achieves such seperation?
>
> class Downloader
> attr_accessor :state_reporter
>
> def dowload(url)
> read_bytes = 0
>
> # open conn
>
> while( chunk = io.read( 1024 ) )
> read_bytes += chunk.length
> # write bytes to file
> self.state_reporter && self.state_reporter.call(url, read_bytes)
> end
> end
> end
>
> d = Downloader.new
> d.state_reporter = proc {|url, bytes| puts "read #{bytes} from #{url}"
>
> d.download 'http://foo/bar'
>
> You get the picture...
>
>
>
>