문제

I have a novice question. I'm reading the book "Erlang Programming" and working on exercises after every chapter.

In the situation that I have a db.erl module, and inside it I've placed several functions for several exercises. After a few days of playing with exercises I've grown tired from repeating "compile->execute exercise-function" actions in the erl shell. Let's say I'm working on new() function in the db.erl module; after each modification of this function, I'm forced to do next in erl:

c(db.erl).
db:new().

again and again. Sometimes I forget to re-load my module and the results are confusing. I can compile/load through OS shell using: erl -compile file.erl; erl -make, but I did not find a way to run specific function from specific module. Any suggestions?

도움이 되었습니까?

해결책

You can use -eval option:

$ erl -eval 'io:format("printing ~p~n", [{any, term}]), init:stop()' -noshell
printing {any,term}

Read documentation here: http://www.erlang.org/doc/man/erl.html

And you can use just erlc to compile files: http://erlang.org/doc/man/erlc.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top