[erlang-questions] escript cutting output

Tim Watson <>
Sat Nov 19 10:45:44 CET 2011


Hillarious. :)

I was wondering if waiting on receive would help, but of the course
the issue was the time being taken by the io:format call and that
didn't change until you added the extra call(s). I've certainly
learned something useful about the io subsystem on this thread and
will poke around in the code to learn more.

On 19/11/2011, Bob Gustafson <> wrote:
> Yes, I agree. That cartoon sums up my motivation..
>
> On Sat, 2011-11-19 at 01:26 +0000, Tim Watson wrote:
>> You forgot the most important line:
>>
>>
>> %% Example: http://xkcd.com/386/
>>
>> Perhaps, like me, you were typing on a phone whilst standing on a
>> crowded train.
>>
>>
>> On 19 November 2011 00:29, Bob Gustafson <> wrote:
>>         After spending too much time learning Erlang over the last few
>>         hours, I
>>         think I have come up with a 'solution' to Matthias' well posed
>>         example
>>         script. See below.
>>
>>         #!/usr/bin/env escript
>>          main(_) ->
>>            S = self(),
>>            spawn_link(fun() ->
>>               io:format("~p~p~n", [lists:duplicate(100000, $a), b]),
>>
>>               io:format(""), %**
>>               S ! finished
>>            end),
>>            receive
>>              finished ->
>>
>>                  io:format(""), %**
>>                  halt(0);
>>              _Other ->
>>                  halt(1)
>>            end.
>>
>>
>>         This script emits a string which *does* end in 'b'.
>>
>>         If you comment out either of the added lines followed by %**,
>>         then it
>>         will emit a shorter string not ending in 'b'.
>>
>>         Bob G
>>
>>         _______________________________________________
>>         erlang-questions mailing list
>>         
>>         http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
>
>
>



More information about the erlang-questions mailing list