From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 657B5BC84 for ; Wed, 13 Apr 2005 02:14:53 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j3D0EqY8013938 for ; Wed, 13 Apr 2005 02:14:53 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA26347 for ; Wed, 13 Apr 2005 02:14:52 +0200 (MET DST) Received: from out1.smtp.messagingengine.com (out1.smtp.messagingengine.com [66.111.4.25]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j3D0Ep9R008154 for ; Wed, 13 Apr 2005 02:14:52 +0200 Received: from frontend2.messagingengine.com (frontend2.internal [10.202.2.151]) by frontend1.messagingengine.com (Postfix) with ESMTP id 0F8E7C729E4 for ; Tue, 12 Apr 2005 20:14:50 -0400 (EDT) X-Sasl-enc: LfNh/nvzRl13Gu+wMfOIQA 1113351288 Received: from [172.16.112.115] (burnham.ljcrf.edu [192.231.106.2]) by frontend2.messagingengine.com (Postfix) with ESMTP id C505E57035A for ; Tue, 12 Apr 2005 20:14:48 -0400 (EDT) Date: Tue, 12 Apr 2005 17:14:39 -0700 (PDT) From: Martin Jambon X-X-Sender: martin@localhost To: caml-list@inria.fr Subject: Coercion of arrays of objects (and some other containers) Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at concorde with ID 425C647D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 425C647B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; arrays:01 val:01 arrays:01 coerced:01 hash:01 ...:98 workaround:01 expression:01 coercion:01 jambon:01 jambon:01 objects:02 objects:02 unit:02 unit:02 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.2 X-Spam-Level: Here is my problem: # let obj = object method a = () method b = () end;; val obj : < a : unit; b : unit > = (* That is nice: *) # ([ obj ] :> < a : unit > list);; - : < a : unit > list = [] (* But why doesn't it work with arrays? *) # ([| obj |] :> < a : unit > array);; Characters 1-10: ([| obj |] :> < a : unit > array);; ^^^^^^^^^ This expression cannot be coerced to type < a : unit > array; it has type < a : unit; b : unit > array but is here used with type < a : unit > array Only the first object type has a method b In practice I have this problem with a hash table of objects, and I expected it to work since it works fine with lists of the same type of objects... Is there any workaround? Martin -- Martin Jambon, PhD http://martin.jambon.free.fr