Version française
Home     About     Download     Resources     Contact us    
Browse thread
How to do this properly with OCaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alex Baretta <alex@b...>
Subject: Re: [Caml-list] "Just say no!" campaign against Obj [was: How to do this properly with OCaml?]
Xavier Leroy wrote:
>>I was constructing a binary heap of tuples the other day.  After pondering
>>these options, I just used Obj.magic 0 as the null value in the array.
>>The heap was in a module, so nothing else could see the array, and I could
>>prove that the code never accessed the null elements, so the use of
>>Obj.magic seemed justified.
> 
> 
> In other terms:
> 
> " I was walking in the city the other day.  I saw a syringe lying on
>   the sidewalk.  I stuck the needle in my forearm.  That was a classy
>   neighborhood, so the use of the syringe seemed justified. "

Once upon a time I felt a desperate need for polymorphic recursion. At
that time the INRIA gang was selling a new ligth drug whose effects are
similar to polymorphic recursion. They called it "polymorphic records".
Polymorphic records do not give addiction--unlike polymorphic variants,
which are much more dangerous from this point of view--but when they are
used to attain that euphoric state of mind given by polymorphic
recursion, they must be injected in one's code with Obj.magic. Yes, i
picked up the syringe and used it. Yes, I got ill with type-unsafety,
but eventually careful medication made me recover. At the end, I must
say experiencing polymorphic recursion was well worth the pain that came
from using Obj.magic.

Notwithstanding my experience, I agree with Xavier that is the social
duty of us all to discourage the young generations to take Obj as a
means to escape the conventional type system imposed upon them by
society. We must convey the idea that the type system the elders have
perpetuated since the time of the professor Church is for their own
good! So, when confronted with Obj, guys, "Just say no!"

Yet, I believe we must make some allowance for the need for polymorphic
recursion. If the laws of the compiler allowed type annotations to
substitute type-inference alone--not type-checking--for the sake of
having type-safe polymorphic recursion, then, maybe, less young people
would be deceived into taking the road of Obj, which inevitably leads to
a segfault.

;)

Alex

-- 
*********************************************************************
http://www.barettadeit.com/
Baretta DE&IT
A division of Baretta SRL

tel. +39 02 370 111 55
fax. +39 02 370 111 54

Our technology:

The Application System/Xcaml (AS/Xcaml)
<http://www.asxcaml.org/>

The FreerP Project
<http://www.freerp.org/>