Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having trouble getting spawn to work in Erlang using Erlide/Eclipse #145

Closed
plaasjaapie opened this issue Dec 30, 2013 · 6 comments
Closed

Comments

@plaasjaapie
Copy link

I'm a newbie with Erlang working my way through tutorials and am working with Erlang in a Windows environment and Eclipse and the Erlide plug-in. Has anybody using this environment had trouble getting the spawn feature to work?

I get the feeling that there is some sort of setting within Eclipse/Erlide that I needed to have set before starting work. Has anybody run into this problem or have any idea what might be wrong?

It doesn't seem to be a bug within Erlide/Eclipse as such in that this guy gives a tutorial and it works fine.

http://www.youtube.com/watch?v=IF4Qsxpwzzs

This is why I think it is more of a setting issue than a bug in Erlide.

@vladdu
Copy link
Collaborator

vladdu commented Dec 30, 2013

Could you please be more specific about what is not working?

When connecting to an erlang node, erlide is just a different (remote) shell process. There are some issues with printing stuff (sometimes the output goes to the wrong place) and maybe this is what you experience - you spawn a process that prints a text which you don't see in the console.

@plaasjaapie
Copy link
Author

Thanks for responding, Vlad!

First I tried this tutorial #11 on youtube...

http://www.youtube.com/watch?v=AS60CMWSzMQ

It is the equivalent of the example shown on page 91, section 4.3.1: Processes of section 4.3: Concurrent Programming of the Erlang/OTP System Documentation that you can download off of the Erlang website. With the youtube tutorial you can see that the results come back to the console. I also tried the example code shown in 4.3.1 with similar result. In both cases, I got no responses on the console and Eclipse/Erlide "locked up" and would not process any further commands until I refreshed the console with a new "Run As" to Erlang. When I refreshed, I could successfully run other parts of the module but not the bit that invoked the spawn option.

I had similar, but not identical troubles with tutorial #14 on yoube...

http://www.youtube.com/watch?v=IF4Qsxpwzzs

The code looks like this...


messageRec() ->
receive
{factorial, Int} ->
io:format("Factorial for ~p is ~p ~n",[Int, factorial(Int,1)]),
messageRec();
{factorialRecorder, Int} ->
{ok,IoDevice} = file:open("L:\Wendy\Erlang\workspace\IO\ConC.dat", write),
factorialRecorder(Int,1,IoDevice),
io:format("Factorial Recorder Done. ~n",[]),
file:close(IoDevice),
messageRec();
Other ->
io:format("Invalid Match for pn",[Other]),
messageRec()
end.

factorial(Int, Acc) when Int > 0 ->
factorial(Int-1,Acc*Int);
factorial(0,Acc) ->
Acc.

factorialRecorder(Int, Acc, IoDevice) when Int > 0 ->
io:format(IoDevice, "Current Factorial Log: pn",[Acc]),
factorialRecorder(Int - 1, Acc * Int, IoDevice);
factorialRecorder(0, Acc, IoDevice) ->
io:format(IoDevice, "Factorial Results: pn",[Acc]).


Here, when I spawned...

Pid = spawn(fun, easy:messageRec/0).

I got a process id like <0.273.0> back like I was supposed to, but when I then tried to invoke either option within messageRec via...

Pid ! {factorial,10}.

I got no response and the system locked up.

I refreshed the Erlang shell and tested both factorial and factorialRecorder separately without messaging and the coding worked properly.

That is the problem that I am encountering. Any guidance that you can give that could get me past this problem will be greatly appreciated.

Best wishes,

Forrest

@vladdu
Copy link
Collaborator

vladdu commented Jan 2, 2014

Can you run these steps in a regular console?

The erlide console doesn't show all error messages and the returned pid is bogus if there was an error (more exactly, the process crashes right after starting). For example the module or function names are misspelled or the module is not accessible. You can call erlang:is_process_alive(Pid) to check that the process is running.

The problem has a ticket and the console is next in line to get a makeover.

@plaasjaapie
Copy link
Author

I haven't tried yet.  That is next on my list of things to do.

On Thursday, January 2, 2014 12:34 PM, Vlad Dumitrescu notifications@github.com wrote:

Can you run these steps in a regular console?

Reply to this email directly or view it on GitHub.

@Carljohnson
Copy link

I too had the same problem as yours. This (http://stackoverflow.com/questions/22546157/erlang-is-not-returning-anything-with-spawn/22565717#22565717) was the solution for me. Hope this will help others as well.

Thank you.

@vladdu
Copy link
Collaborator

vladdu commented Mar 21, 2014

To make it clearer, the fix will be available in version 0.28.

@vladdu vladdu closed this as completed Apr 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants