From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id B1622BC57 for ; Mon, 30 Aug 2010 23:04:25 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoEDABa6e0yM9xyZi2dsb2JhbACgfgEBAQoLChgitkSIZIU3BIoJ X-IronPort-AV: E=Sophos;i="4.56,294,1280700000"; d="scan'208";a="66328020" Received: from math.harvard.edu (HELO abel.math.harvard.edu) ([140.247.28.153]) by mail1-smtp-roc.national.inria.fr with ESMTP; 30 Aug 2010 23:04:25 +0200 Received: from dhcp-0059423277-df-47.client.student.harvard.edu (wrls-249-211-225.wrls-client.fas.harvard.edu [140.247.254.225]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by abel.math.harvard.edu (Postfix) with ESMTP id 04697A5DB for ; Mon, 30 Aug 2010 17:04:24 -0400 (EDT) References: <20100830204956.2D927BC5D@yquem.inria.fr> In-Reply-To: <20100830204956.2D927BC5D@yquem.inria.fr> Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: text/plain; charset=us-ascii Message-Id: <231FBA54-C413-4696-AA70-216253EDF2DA@math.harvard.edu> Content-Transfer-Encoding: 7bit From: Nicolas Ojeda Bar Subject: extending records with Obj.magic Date: Mon, 30 Aug 2010 17:04:22 -0400 To: caml-list@yquem.inria.fr X-Mailer: Apple Mail (2.1081) X-Spam: no; 0.00; extensible:01 int:01 int:01 seems:03 types:05 generated:05 extension:06 nicolas:08 mess:09 actually:10 magic:10 magic:10 obj:11 obj:11 supposedly:11 Hello, I need extensible records, and the code below seems to work. Are there any pitfall that I should be aware of? Could this mess up the GC? # type t0 = { a : int }; # type t1 = { a2 : int; b : int }; # value x1 = { a2 = 3; b = 5 }; # value x0 : t0 = Obj.magic x1; value x0 = { a = 3 } # value x0' : t1 = Obj.magic x0; value x0' = { a2 = 3; b = 5 } (supposedly t1 is an extension of t0). The types are being generated by a program, so I am not worried about actually having to _write_ this myself. Thanks! N