<br>I spent some time on the train hacking away at Erlhive.<br>Now that I'm able to safely handle processes, ets tables<br>and files (at least virtual files) inside mnesia transactions,<br>I thought I'd throw in a HTTP or FTP client as well.
<br><br>I was disappointed to find that neither  the ftp nor the http<br>module are especially clean, doing just what you'd expect.<br><br>My first step in checking how much work is needed to port<br>something into erlhive goes something like this:
<br><br>2> Beam = code:which(ftp).<br>"c:/Program/ERL55~1.4/lib/inets-4.7.11/ebin/ftp.beam"<br>4> {ok,{_,[{imports,Is}]}} = beam_lib:chunks(Beam,[imports]).<br>{ok,{ftp,[{imports,[{application,start,1},<br>
                    {dbg,p,2},<br>                   ...]}}<br>5> Ms = ordsets:from_list([M || {M,_,_} <- Is]).<br>[application,<br> dbg,<br> erlang,<br> error_logger,<br> file,<br> filename,<br> ftp_progress,<br> ftp_response,
<br> ftp_sup,<br> gen_server,<br> gen_tcp,<br> inet,<br> inet_db,<br> io_lib,<br> lists,<br> string]<br><br>Now, going through the list is a bit discouraging.<br>The following dependencies would cause porting problems:<br>
<br>  [application, dbg, error_logger]<br><br>(Ok, inet_db needs to be handled too, but that's a logical step.)<br><br>None of these are needed for the ftp logic, and so I'm forced<br>to first cut out portions of the code. After that, it should be a
<br>pretty clean recompile.<br><br>Now, the bulk of ftp.erl is perfectly fine. It is, as it should be,<br>just a gen_server (but why on earth is it hard-coded to run<br>at low priority?!). But making the module double as a supervisor
<br>behaviour, and automatically bootstrapping the inets application,<br>is unnecessary, I think. <br><br>Why not have a clean ftp gen_server module, and put all the <br>gunk in a wrapper module for those who want it?<br>
<br>Even if porting to Erlhive isn't high on your list, I can think of <br>many good reasons to write the main logic in a separate <br>module, with as few dependencies as possible.<br><br>BR,<br>Ulf W<br>