[clean-list] Clean in the Real World

Arjen van Weelden arjenw@cs.kun.nl
Mon, 15 Dec 2003 09:36:45 +0100


Marco Kesseler wrote:
> Arjen van Weelden wrote:
> 
>>Brent Fulgham wrote:
>>
>>>Does Clean provide something like the exception model proposed in 
>>>Simon Peyton-Jones et. al "A Semantics for Imprecise Exceptions" 
>>>(http://research.microsoft.com/Users/simonpj/Papers/imprecise-exn.htm)?
>>
>>Clean 2.1 for Windows comes with a small library (Libraries\
>>ExceptionsWindows\StdException) that implements user-defined
>>(synchronous) imprecise exceptions using machine dependent ABC-code and
>>Dynamics. At least, it ought to implement just that, but it needs more
>>users to really test it. It should problably be rewritten in assembly,
>>incorporated into Clean's run-time system, and ported to the other
>>platforms.
> 
> 
> Having read a part of the paper of Simon Peyton Jones et al. about 
> imprecise exceptions, I must say that this is not exactly what I had 
> in mind myself.
> 
> A main issue in the paper seems to be - if you implement exceptions 
> via stack trimming - that "getException (a + b)" may not have the 
> same value as "getException (b + a)", if both a and b lead to an 
> exceptional - but different - value. It depends on which one gets 
> evaluated first, and often the compiler decides things for you.
> 
> The writers end up putting getExeption in the IO Monad, and then 
> suddenly it _is_ allowed to non-deterministically choose one 
> exception value, supposedly without hurting referential transparancy. 
> If all the interesting stuff must end up in the IO Monad I'd rather 
> just use a real imperative language (sorry if I hurt anybodies 
> feelings, but some Monad tricks are getting on my nerves).
> 
<snip>

As I see it, catching exceptions is only non-deterministic between 
compilations. There are more functions in the Clean distribution that 
ought to use the !*World -> *World style, but since they are fixed for a 
single run of a program (like getCommandLine, or things like 
getProcessId) they don't. I don't like putting it in the IO 
monad/!*W->*W, and it don't like disturbing ref.transp., but in this 
case the second options suits me best.
I am thinking about changing the 'unsafeX' functions in the StdException 
library to 'X', and the 'X' functions to 'evenSaferX'.
Just like any other expressions in Clean, you cannot assume much about 
the evaluation order, so don't! Make sure that the code handles any 
exception (from both a and b).

regards,
	Arjen