[clean-list] Process starting

Arjen A.vanWeelden at cs.ru.nl
Thu Mar 9 18:38:34 MET 2006


Marco wrote:
>>> > (one more thing: don't use so many #!'s, they are hardly ever necessary)
>>>Yes, thanks, but my problem is a little bit complicated as my small 
>>>example shows that.
>>>I have to call a lot of external C functions, and must implement a real 
>>>sequence, which
>>>cannot be without #! :)
>>>
>>>Thank you for your answers,
>>>
>>
>>Usually, you do this by using environment passing (using the World or 
>>another state) and using # . It forces a sequence based on the data 
>>dependency of the state. This works better that (hoping to) force 
>>evaluation using #!, since its semantics are not well defined. If you're 
>>not careful, #! does not even enforce the evaluation that you 
>>want/expect! This is something I've observed from myself and from other 
>>Clean programmers. Maybe you're an expert and all this does not apply to 
>>you. It was just a suggestion to improve your Clean style.
> 
> 
> Hi Arjen,
> 
> I am aware that this is somewhat off-topic for the subject at hand, 
> but I hope that you appreciate what I want to say nonetheless.
> 
> What I am trying to point out, is that it is often better if 
> programmers explicitly write down their intentions, even if the 
> language does not require it. It makes sense to write down types, 
> even if the compiler can derive them. This becomes important if 
> others have to understand the program.

I do appreciate your comments and I completely agree with you.

> So, if someone uses #!, then everyone knows that the programmer is 
> saying "it is important that this be evaluated now". It does not 
> matter whether the compiler can figure this out too. It matters that 
> other programmers are careful when changing this particular part of 
> the code.

My problem with #! is that it does not exactly mean "evaluate now" and 
it may not "evaluate this" at all. The Clean compiler sometimes 
reshuffles multiple #!'s and it only forces the outermost data structure 
to whnf, which usually, especially with lazy tuples, is not what you 
want. I'm not even mentioning that it spoils (formal) reasoning about 
the code. My problem with "explicitly writing down intentions" using 
#!'s is that it's really difficult to do so. Even when one gets it 
right, the reader may have a different intuition about the semantics of #!.

> 
> Apart from that, it is not always that easy, or natural to drive a 
> "procedure" (as opposed to a function) via data dependencies alone.

That is true. Nevertheless, environment passing does always work, 
doesn't get reshuffled without respect to data dependencies, and using ! 
in the type of the Clean wrapper of the external function has a much 
better defined semantics. I really agree with you on all points, expect 
on the use of #!.

> And finally: given that endless debates have occured over the right 
> way to place curly brackets in C, I suspect that there is no such 
> thing as the "right" Clean style.

> cheers,
> Marco

Of course, it is wrong of me to try to enforce my style upon anyone 
else, I should have formulated my objections better. It's just that the 
semantics of #! are dubious and I haven't found two people yet who agree 
on what it does and/or should do. I'm sorry for bothering people on the 
Clean list with my own personal frustrations about #!.

cheers,
	Arjen


More information about the clean-list mailing list