[erlang-questions] Why doesn't erl_eval compile code?

Robert Virding <>
Fri Jul 10 14:42:17 CEST 2009


2009/7/9 Tony Arcieri <>

> On Wed, Jul 8, 2009 at 4:46 PM, Robert Virding <> wrote:
>
>> The basic problem is that you are trying to use the code system in a way
>> we never intended.
>
>
> Yes, at times I feel like I'm in square peg round hole territory.  Usually
> when I reach this point I try to take a step back and do things in an
> Erlangier way.  I now see the reasoning behind why Erlang implements eval
> metacircularly.  However, if there's one thing that sets scripting languages
> apart from other languages I believe it's extensive use of eval and runtime
> code generation/execution.  In that regard you might call Lisp the world's
> first scripting language (although I believe that honor is typically
> attributed to awk)
>

I think that many scripting languages probably do interpret the code
internally and don't compile it, though I haven't studied them so I am not
certain. What makes lisp (and prolog for that matter) so useful as a
scripting language is that most implementations allow you to freely intermix
compiled and interpreted functions. Which Erlang does not, and that when it
manages code it manages whole modules not functions, and that modules are
compiled.

I ran into exactly the same problem with LFE, plus that lisp also has macros
as separate entities.

However, it's a lot easier to write a metacircular evaluator for a Lisp than
> for something like Reia...
>
>
>> To do this properly as you intend would mean a rewrite of the code system,
>> which would probably result in changes all over the place. But it would be
>> more beautiful. :-(
>>
>
> I'm okay with hacks as long as they work :)


In this case using soft_purge and having a process which occasionally tries
to remove your temporary modules would be the hack. Looking at the
documentation for soft_purge seems to imply that it is fun safe, but try it.

Robert


More information about the erlang-questions mailing list