Version française
Home     About     Download     Resources     Contact us    
Browse thread
Converting variants with only constant constructors to integers
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Kaustuv Chaudhuri <kaustuv.chaudhuri@i...>
Subject: Re: [Caml-list] Converting variants with only constant constructors to integers
On Tue, Jun 8, 2010 at 4:37 PM, Jacques Garrigue
<garrigue@math.nagoya-u.ac.jp> wrote:
> Of course intify can cause a segmentation fault!
>
> # let arr = Array.of_list [intify 1.0; 0];;
> Segmentation fault

This may be splitting hairs, but the reason that fails is that
Array.of_list's ad hoc polymorphism heuristic assumes that if the
first element of the list is allocated, then all elements are
allocated. Merely changing the order works.

  # Array.of_list [Obj.repr 0 ; Obj.repr 1.0] ;;
  - : Obj.t array = [|<abstr>; <abstr>|]

Which one of Obj.repr of Array.of_list to blame, if that's the right
word, is not that relevant to any code a sane person might write.

-- Kaustuv