<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>But you can specify here a function that you have written
somewhere, then in that function read the configuration parameters
that you want to use? For Erlang only the signature matters, i.e.
that the function accepts the arguments that the documentation
says it should accept and that it returns the value it should
return (e.g. boolean()). It's entirely up to you what the function
does inside, e.g. it can execute some Java code, read a config
file, or randomly return true/false.</p>
<p>What I was more interested is why do you think you need to
specify anything in configuration related to those functions, why
they can't be just static functions implemented somewhere.</p>
<p>Greg<br>
</p>
<br>
<div class="moz-cite-prefix">On 09/07/2018 21:06, Code Wiget wrote:<br>
</div>
<blockquote type="cite"
cite="mid:e12603c7-7611-443e-bbed-56a094c8f7c7@Spark">
<title></title>
<div name="messageBodySection" style="font-size: 14px;
font-family: -apple-system, BlinkMacSystemFont, sans-serif;">Hi
Greg,
<div><br>
</div>
<div>I sent this earlier, but it must not have gone through to
everyone. I am trying to use special ssl options, for example:</div>
<div><br>
</div>
<div>
<p style="margin: 0px; font-stretch: normal; line-height:
normal; font-family: "Helvetica Neue"; color:
rgb(51, 51, 51);">{reuse_session, fun()}
{next_protocols_advertised, [binary()]}</p>
<p style="margin: 0px; font-stretch: normal; line-height:
normal; font-family: "Helvetica Neue"; color:
rgb(51, 51, 51); min-height: 16px;">And</p>
<p style="margin: 0px; font-stretch: normal; line-height:
normal; font-family: "Helvetica Neue"; color:
rgb(51, 51, 51);">{user_lookup_fun, {fun(), term()}},
{psk_identity, string()}, {srp_identity, {string(),
string()}}</p>
<p style="margin: 0px; font-stretch: normal; line-height:
normal; font-family: "Helvetica Neue"; color:
rgb(51, 51, 51);"><br>
</p>
<p style="margin: 0px; font-stretch: normal; line-height:
normal; font-family: "Helvetica Neue"; color:
rgb(51, 51, 51);">Which require functions as input. This
means that I can’t use a configuration file. Other members
have suggested that I iterate over my environment variables
and replace the “fun()” with a function at run time, rather
than using a .config file. I think this is the most
straightforward approach.</p>
</div>
</div>
<div name="messageReplySection" style="font-size: 14px;
font-family: -apple-system, BlinkMacSystemFont, sans-serif;"><br>
On Jul 9, 2018, 5:04 PM -0400, Grzegorz Junka
<a class="moz-txt-link-rfc2396E" href="mailto:list1@gjunka.com"><list1@gjunka.com></a>, wrote:<br>
<blockquote type="cite" style="margin: 5px 5px; padding-left:
10px; border-left: thin solid #1abc9c;"><br>
<div class="moz-cite-prefix">On 09/07/2018 18:57, Code Wiget
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:97239fa3-1e1c-4f6d-899f-f759b7e2964c@Spark"
style="margin: 5px 5px; padding-left: 10px; border-left:
thin solid #e67e22;">
<div name="messageBodySection" style="font-size: 14px;
font-family: -apple-system, BlinkMacSystemFont,
sans-serif;">Hi,
<div><br>
</div>
<div>Say I want to include a function as an environment
variable</div>
<div><br>
</div>
<div>I can do this:</div>
<div> application:set_env(App, Key, NewValue). <br>
</div>
<div><br>
</div>
<div>Is there any way to do this from a .config file? Such
as:</div>
<div> [{my_app, [ {my_fun,
#Fun<my_app.12.39472874>}]}]</div>
<div><br>
</div>
<div>— this gives a compile error. </div>
</div>
<br>
</blockquote>
<br>
If you defined a function in the config how would you verify
if it's correct? You will need to compile it first. In Erlang
you can compile any arbitrary file directly in your
application, see this for an example:<br>
<a class="moz-txt-link-freetext"
href="https://github.com/yoonka/migresia/blob/master/src/migresia_migrations.erl#L193"
moz-do-not-send="true">https://github.com/yoonka/migresia/blob/master/src/migresia_migrations.erl#L193</a><br>
<br>
So, theoretically, you could define a function as a string or
binary in your config, then in the application write this to a
file, compile into a binary (i.e. without writing the compiled
module to a file) and then load directly from that binary and
execute. But that sounds a bit weird and it's probably not
what you need. Maybe you can just tell us what are you trying
to accomplish?<br>
<br>
Best<br>
Greg<br>
</blockquote>
</div>
</blockquote>
<br>
</body>
</html>