Ok, so it's been a while. gnat's latest journal mentions me thusly: "the last part of that list is people who haven't updated their journals in months," so it's probably time to update :)
The reason I found myself not posting to use.perl as often as I'd like (or as often as I posted to the quasi-blog on my website) was that almost every entry had entirely nothing to do with perl. Other people may find that acceptable, but I always felt a little strange about posting to use.perl about everything *but* perl.
But with my server MIA for the last week and a half (zoidberg, where are you!), I suppose I can just start puting my ramblings on use.perl again.
On the perl front, I've been wrestling with B::Generate (finally under a threading perl - thanks Arthur!), and am having a wonderful time causing segfaults from perl-land. No, really. It's great! ... I mean, it's better when it doesn't segfault, but even the segfaults are fun :) Anyway, I can't seem to figure out how to create a new CV with B::Generate - can this be done? It seems like I should be able to just instantiate a B::CV object and set the root and start ops, but B::Generate doesn't seem to provide a constructor for B::CV. Has anyone done this, or know how to do this?
I'm also having trouble doing this. The best reference I've found so far is Simon's 'use Python' paper in last year's TPC proceedings. He has an example of creating a new anonymous sub, calling svref_2object() on it, and manipulating its START and ROOT ops.
I can get pretty close, but never quite avoid the segfaults. It probably doesn't help that I'm trying to pass the rewritten subref to B::Deparse, either.
Re:B::Generate
kasei on 2002-07-15T07:48:54
Thanks for the tip. I had read Simon's paper last year when I got into this project (and scanned it at TPC), but had completely forgotten that he did just what I wanted in the paper. I've now got working code that creates an anon. sub which contains the code from the main_cv (minus the enter and leave ops). Little tweaks are necessary for things like constants that are optimized away and need to be reset with the sv method, but it looks to be working.
Thanks again!Re:B::Generate
chromatic on 2002-07-15T14:53:09
I'm glad to help. Is there a chance you'd be willing to share the code? I'm curious to see another example. (I don't have unfolded constants yet, and that would be handy.)
Re:B::Generate
kasei on 2002-07-22T10:01:36
Sorry about the delay in responding. I'd be happy to post my code, but it was a bit of a hack, and I've just recieved an email from Simon describing how to do it the right way (for some definition of right).
I kind of try to filter anything I'm thinking about Perl (well, anything that isn't pure fanboyishness, that I save for my livejournal) and anything I was thinking about school into my use.perl; journal. (With a certain granularity difference; school-stuff had to be at least about an assignment as a whole, nothing too detail-oriented as a rule. Anything Perl is free game, including stupid bugs I left in code, errors I don't know how to work around, how my experience with a module is going, etc. I'm worried about making the same stupid mistakes over and over.)
Now that my job hunt's (sort of) over, I'm just talking about the code for my final project. After that, I'll (surprisingly) feel very relieved to start working on the Perl/Tk interface to use.perl; journals again.