[erlang-questions] Erlang and beam-based scripting languages.

Max Lapshin max.lapshin@REDACTED
Tue Sep 13 14:05:56 CEST 2011

On Tue, Sep 13, 2011 at 3:42 PM, Vlad Dumitrescu <vladdu55@REDACTED> wrote:

> Do I understand correctly that you would like to have a module loader
> that accepts registrations for file type handlers and whenever it
> doesn't find a .beam file for a module, asks these handlers if they
> can find a source file and compile+load it? That would be cool.

Exactly. But there is comment in code_server looking like "leave hope
anyone, who is going to change this module, many brave Swedens are
lying here"
and I'm a bit afraid to edit it =)

> The
> only delicate issue I see right now is how to find these source files,
> if the source directories aren't added to the code path.

I think, best behaviour is to look inside code path. No code path, no modules.

I've tried to take  elixir and load it. Currently it is looking so
(doesn't do any real job, just for example):


module DigitalAccess
  def check(host, name, options)
    IO.puts "Called with #{host} #{name} #{options.inspect()}"
    {ok, headers, reply} = Erlang.http_stream.get_with_body("http://ya.ru/", [])
    url = "http://video.ru/movies/"+headers['"Content-Length"]
    [{'type, 'file},{'url, url},{'file_access,'http_file}]

(ev@REDACTED)1> code:add_pathz(code:lib_dir(elixir,exbin)).
(ev@REDACTED)2> application:start(elixir).
(ev@REDACTED)3> elixir:file("digital_access.ex").
(ev@REDACTED)4> SomeUnknownArgument = [].
(ev@REDACTED)5> 'exDigitalAccess':check([], default, <<"http://ya.ru/">>,
[{url, <<"zzz">>}]).
Called with default http://ya.ru/ [{'url,"zzz"}]

So it really looks very close to what I want, except module name and
automatic loading.

More information about the erlang-questions mailing list