[EMAIL PROTECTED] schrieb:
> "Joachim Durchholz" <[EMAIL PROTECTED]>:
>> Hmm... I think having a global facilities accessible to all processes
>> has problems once a program turns into a subprocess. Programmers would
>> have to make sure that no stray OS.Process.exit or OS.Process.success is
>> left in that code.
> 
> I'm not sure what you mean by subprocess here.

Sorry, I meant threads.
(Erlang terminology creeping in...)

 > Another process won't be
> affected by an exit call. Other threads sure will, but they are just that:
> threads of control flow, sharing state and everything, not independent
> entities.

Ah, I understand what you say.
I don't fully understand the decision though. One of the highlights of 
FPLs is that you have as little state as possible, yet the concurrency 
mechanism of Alice uses shared state - or did I get that wrong?

>> So what about charging the first ("main") thread with setting the exit
>> code, and terminating the system when the last thread has exited?
> 
> While that may seem like an obvious answer, it does not work. First of
> all, there isn't really a "main" thread.

 From the perspective of the VM, there may not be. From the perspective 
of the programmer, there certainly is.

 > All threads are equal, and the VM
> already spawns several threads on startup, most of which conceptually run
> forever.

Right.
The VM could still exit when no useful work is in the system anymore.
E.g. when all threads have an empty message queue, and no asynchronous 
requests to external entities (keyboard, timer, file system etc.) are 
pending anymore.

 > Furthermore, relying on implicit exit would necessary require you
> to know whether, say, a library that you are using spawns threads - which
> violates abstraction.

No, the idea is that the main thread is charged with setting the 
program's return code.
The library might want to set the return code, too. In that case, it 
would have to provide a function that returns the return code.

In other words, if the library sets the return code, it is violating 
abstraction anyway because it sets a global variable. Better make that 
explicit. Even better place it in the return value of a function.

Regards,
Jo

_______________________________________________
alice-users mailing list
[email protected]
http://www.ps.uni-sb.de/mailman/listinfo/alice-users

Reply via email to