[resent because of my other email address is not subscribed - bah]
[EMAIL PROTECTED] wrote: >> Is this what you were thinking of? > >No. At least, not until B::Deparse works on 100% of perl code. And of >course, the browser needs to come back to the user and query for the >names of the arguments and of the method, replace the code with a >method call, preferably using named parameters, and generally make the >place look nice. I think the problem I was trying to solve was more along the lines of how could I write something to turn a piece of code that relies on globals into a method that relies on lexicals, without writing a parser. I'm just playing around now with comparing chunks of the optree to the original code, and attempting to get enough info back from the optree to figure out where I need to place the method call - theory being that while the perl source code may change its variable names fairly significantly, the optree looks more or less the same. Of course any milage that I may gain here is subject to extremely hairy conditions in the first place. Of course at the moment its just comparing the output to B::Terse - but seeing as B::Terse is a textual representation of the optree, what works with one should work with the other. >And 'Make method' is just one of the refactorings that a good >refactoring browser should do, need things like 'rename method', 'push >method to superclass'... Absolutly - I'm looking at starts rather than ends :-) >If I can get it to work it's going to be *so* cool. The other thing I'd really like is a proper class browser. I've hacked together class browsers in the past, but they always are just a hack, although I've not done anything since B::Deparse became more clever. >However, that is a *really* cool approach. Took a while to work out >what was going on mind, but still, very cool. It is pretty hairy. What I meant above was 'let Perl worry about parsing perl, and let me worry about errors that are generated'. Essentially that is the approach - Damian (uses|used) a similar method for parsing arguments to attributes in Attribute::Handlers. >Now, if Robin can just get B::Deparse working all the time... But I >don't think we'll be seeing that until 5.10... I've not read p5p for a little while. I was under the impression that code spat out by B::Deparse was passing any test that wasn't reliant on order of BEGIN blocks (and therefore things like pragmata where a little bit squew whiff[0]). Regards, James [0] I've always loved this expression. I've never seen it spelled however, so this may be very wrong.