From: Hugh Sasse Staff Elec Eng Date: 2004-03-05T00:52:39+09:00 Subject: Re: concerns about Proc,lambda,block On Thu, 4 Mar 2004, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: concerns about Proc,lambda,block" > on 04/03/04, Hugh Sasse Staff Elec Eng writes: > > |I'm not sure what the right thing to do would be: sometimes > |simplicity is acheived by similarity, other times by difference. > |However, I think some kind of reflection would be useful, whatever > |you decide. Maybe a wrapped?() method might be useful, so at least > |when debugging we can ask the code "Are you a wrapped proc or not?" > > I don't know. I wonder why you care if wrapped or not, where you > cannot get the definition of the proc body. For debugging purpose, Because it affects how return and errors are handled. The method that does something with this may be able to decide (based on what it has received) how to deal with failures, it may wrap the proc in a Thread.new(...){...}.value or something. Also it improves clarity of code in the same way that block_given? does. I can't really think of an example, but I think that is more my lack of imagination than anything else. Reflection in code is a good thing, isn't it? > you can get the source position of the Proc, for example, > > # But it's difficult to do anything programmatically with that, and it is not so readable as most ruby! :-) > > by Proc#inspect. > matz. > Hugh