[erlang-questions] "dynamic" include?

Torbjorn Tornkvist tobbe@REDACTED
Fri Oct 26 08:45:43 CEST 2007


YC wrote:
> Hi all -
> 
> is it possible to include programmatically generated path?
> 
> i.e.
> 
> instead of
> 
> -include("../../foo.hrl").
> 
> write
> 
> -include(dynamic_determine("foo.hrl")).

As it happends, I recently read (in the Erlang Handbook) that you
apparently should be able to do this:

 -include("$PATH/foo.hrl").

so in principle you should be able to do:

 -include("$WHATEVER").

I haven't verified that this works though...

Cheers, Tobbe


> 
> I suspect not (the above don't compile for me), but the idea is that you
> might not know for sure where the file would be, and rely on the vm to
> figure it out via the code:which() mechanism.  For example, yaws can be
> installed locally or globally, and if you need access to yaws hrl files,
> you can't depend on it exist @ a particular location (assuming your code
> branch has no relation with yaws' code branch), and it's a pain if one
> has to modify the source if the locations differ.
> 
> What's the best practice to deal with such situation?  Any thoughts are
> appreicated, thanks.
> yc
> 




More information about the erlang-questions mailing list