Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!pphillip From: pphillip@cs.ubc.ca (Peter Phillips) Newsgroups: comp.lang.perl Subject: Re: can we ever compile perl? Message-ID: <1990Dec12.064530.22356@cs.ubc.ca> Date: 12 Dec 90 06:45:30 GMT References: <9592:Dec920:40:5190@kramden.acf.nyu.edu> <110306@convex.convex.com> Sender: news@cs.ubc.ca (Usenet News) Organization: University of British Columbia, Vancouver, B.C., Canada Lines: 46 In article <110306@convex.convex.com> tchrist@convex.COM (Tom Christiansen) writes: >In article <9592:Dec920:40:5190@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: >>1. Compile some large subset of the language to portable C code. > >We usually say "well, but not evals of course." I've a suspicion >that this rules out a lot of code. For example, a user guy mailed >me recently with a problem that had a quick eval answer, and I'm >thinking that saying "no evals in compiled code" really limits >a large subset of the language. Here's the problem: [ string replacing problem omitted ] >Notice that I've used not one but two evals in this little program. >Of course, this is too short to bother wanting to compile (unless >someone has other motivations than speed for compilations), but I >think it illustrates the problem: evals are just too darn convenient. >I don't really want to think about how I might do that if I couldn't >have an eval, but I don't know how to compile it with one either. For some perl scripts, eval is indispensible. The debugger wouldn't work without it. For other scripts, eval can be replaced by less powerful operations. Eval is often used to get at the regular expression compiler built into perl. If perl had a regular expression variable and a regular expression compile function, code fragments like: eval "s/$find/$repl/g"; Could be replaced with the translatable-to-C code version: $pat1 = &compile_pattern($find); $pat2 = &compile_pattern($repl); s/$pat1/$repl/g; Something like this could be added to perl, I think. There are other common uses for eval, like simulating references. I think with the right modifications, most uses of eval could be eliminated. Perhaps the greatest and wisest perl hackers should get together, examine their scripts which use eval, and decide what reasonable extensions to perl would eliminate 90% of the use for eval. -- Peter Phillips, pphillip@cs.ubc.ca | "It's worse than that ... He has {alberta,uunet}!ubc-cs!pphillip | no brain." -- McCoy, "Spock's Brain"