From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA26754; Fri, 7 May 2004 18:18:59 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 SAA26592 for ; Fri, 7 May 2004 18:18:57 +0200 (MET DST) Received: from gatekeeper.elmer.external.excelhustler.com (gatekeeper.excelhustler.com [68.99.114.105]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i47GIuEV025442 for ; Fri, 7 May 2004 18:18:56 +0200 Received: from chatterbox.elmer.internal.excelhustler.com (unknown [192.168.0.12]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (Client CN "chatterbox.elmer.internal.excelhustler.com", Issuer "excelhustler.com" (not verified)) by gatekeeper.elmer.external.excelhustler.com (Postfix) with ESMTP id C042AE011F; Fri, 7 May 2004 11:18:55 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by chatterbox.elmer.internal.excelhustler.com (Postfix) with ESMTP id 8AC2B5C006; Fri, 7 May 2004 11:18:55 -0500 (CDT) Received: from wile.internal.excelhustler.com (wile.internal.excelhustler.com [192.168.1.34]) by chatterbox.elmer.internal.excelhustler.com (Postfix) with ESMTP id 776C35C004; Fri, 7 May 2004 11:18:55 -0500 (CDT) Received: by wile.internal.excelhustler.com (Postfix, from userid 1000) id 715614406D; Fri, 7 May 2004 11:18:55 -0500 (CDT) Date: Fri, 7 May 2004 11:18:55 -0500 From: John Goerzen To: caml-list@inria.fr Subject: [Caml-list] Differentiating lists from arrays with Obj Message-ID: <20040507161855.GA29940@excelhustler.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.5.1+cvs20040105i X-Scanned-By: clamscan at chatterbox.elmer.internal.excelhustler.com X-Miltered: at nez-perce with ID 409BB6F0.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; doubles:01 floats:01 doubles:01 eep:99 arrays:01 arrays:01 ints:01 int:01 worse:03 identical:03 identical:03 obj:03 obj:03 types:03 types:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, I am looking at using the Obj to access internal representations of some types. I have figured out how to access those types for ints, doubles (floats), strings, and arrays of doubles (why those are special, I have no idea!). I can also figure out how to access lists and arrays, for which Obj.tag returns zero. (Although that value does not occur in obj.ml, it is in some of the header files.) Now, here's the question: how can I accurately differentiate lists from arrays? Lists appear to be internally represented by structures that look somewhat like this: [1; [2; [3; 0]]] That is, Obj.size will return 2 for the list [1; 2; 3] because it is a collection of an int and a list. That's fine, but its internal representation of the list [1] is: [1; 0] Which happens to be identical to the representation of the array [| 1; 0 |]. Eep. Now, it's not a big deal to me whether I've got a list or an array, but I need to be able to know whether that list or array has an extra 0 at the end. Worse, the internal representation of [] appears to be identical to the internal representation of the integer 0. I am a little puzzled here, and I do not know the type of the data I'm dealing with in advance. Thanks for any enlightenment. -- John ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners