logo       


Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Metaprogramming: msg#00007

Subject: Metaprogramming
Hi fwp,

once again, I'm thinking about some borderline fun with perl. "Borderline" because of the buzzword in the subject line that should repel all but the sickest and the .com types. (Now, which would I be?)

I've been wondering whether it is possible to implement some kind of mechanism that allows a Perl script to modify itself at runtime. Performance is not an issue as this isn't anything you'd want to use in production code. :)

So far, I see no way of achieving this. Using source filters, one may modify the source at compile-time and in fact I spent an hour doing so. (For a good reason, I never used source filters before, so it took me a bit to write that code.)

The result is Acme::Metification. Horrible name for a horrible hack.
http://search.cpan.org/author/SMUELLER/Acme-Metification-1.00/

Since the last upload, I have modified the module so you can define markers relative to which the positions of the "meta*" commands are interpreted. Additionally, I *should* be able to allow the functions to accept line numbers at run-time. (eg "meta marker $startline, $endline)

I would do that by inserting code for the meta command that determines $startline and $endline at runtime and evaluates the corresponding lines. (The code would have been originally generated in the lexical scope of the original array of code lines in the source filter.) Of course, in order to allow recursive "metaprogramming", one'd have to filter the code-to-be-evaluated first and apply the same transformations that were done to the rest of the source if necessary. (Which is a pain to implement but nevermind.)

I suppose I have successfully twisted most of your brains with that paragraph of bad english and bad ideas. ;)

What I am really interested in is a few better ideas on how one could go about implementing some concept of LISP-like metaprogramming for Perl. Any better ideas than the above?

Steffen
--
sub'_{q} tsuJ}}_();sub's{seek+DATA,0,0}sub'p{print&_}sub'r{reverse$_[0]}
@_=(('')x2,split"  ",<DATA>);s!!&s,$_=<DATA>;s/}.*?}/$_[$s+1]/
if$s;s/(}.*?})/r$1/e;eval$_;p,$s++!efor@_[0..3];
__DATA__
} rehtona}  } lreP}  },rekcah}





Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
db.firebase.por...    text.xml.xalan....    qnx.openqnx.dev...    user-groups.zar...    internationaliz...    kde.devel.konve...    finance.e-gold....    emacs.latex.pre...    gis.therion/200...    web.webmin.gene...    yellowdog.gener...    vserver/2003-08...    redhat.release....    sysutils.tivoli...    xfree86.expert/...    mail.becky.user...    hardware.netapp...    netbsd.ports.xe...    python.distutil...    boot-loaders.gr...    culture.interne...    java.springfram...    activedir/2006-...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe