returning bindins from file:script

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

returning bindins from file:script

Karlo Kuna
i am currently working on "file fold" module.
files are erlang scripts (as input to file:script/2) and i want to pass 
bindings structure form one call of file:script/2 to another adding to it as 
scripts are evaluated. 

does anyone have elegant solution for this? or at least idea how to do it (except 
making alternative to file:script)

thanks


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: returning bindins from file:script

Joe Armstrong-2
I suggest you read the source of file.erl - and in particular the routine
eval_stream2/6 - this returns {ok, Val} so you loose the bindings
change this is {ok,Val,Bindings} and use these when you process the next file.

If you read the code in file.erl and look at file:eval(File)

You see that basically only three routines are involved:

erl_eval:new_bindings/0 - creates  the initial bindings
io:parse_erl_expressions/3 - parses the input data
erl_eval:exprs/2 - evaluates a sequence of parsed expressions

The module erl_eval does all the hard work for you

Cheers

/Joe

On Fri, Jul 20, 2018 at 10:25 PM, Karlo Kuna <[hidden email]> wrote:

> i am currently working on "file fold" module.
> files are erlang scripts (as input to file:script/2) and i want to pass
> bindings structure form one call of file:script/2 to another adding to it as
> scripts are evaluated.
>
> does anyone have elegant solution for this? or at least idea how to do it
> (except
> making alternative to file:script)
>
> thanks
>
>
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions
>
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions