From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 7F3E9BBAF for ; Sun, 31 May 2009 07:18:59 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAKqvIUrOe3NG/2dsb2JhbADOGoQMBQ X-IronPort-AV: E=Sophos;i="4.41,278,1241388000"; d="scan'208";a="27084068" Received: from spoomusic.com ([206.123.115.70]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 31 May 2009 07:18:58 +0200 Received: (qmail 4051 invoked by uid 89); 31 May 2009 05:18:56 -0000 Received: from unknown (HELO ?192.168.1.99?) (98.165.129.233) by 0 with ESMTPS (DHE-RSA-AES256-SHA encrypted); 31 May 2009 05:18:56 -0000 Message-ID: <4A22132E.30505@ramenlabs.com> Date: Sat, 30 May 2009 22:18:38 -0700 From: Dave Benjamin User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103) MIME-Version: 1.0 To: Dario Teixeira Cc: Till Varoquaux , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Width subtyping References: <380372.47429.qm@web111503.mail.gq1.yahoo.com> In-Reply-To: <380372.47429.qm@web111503.mail.gq1.yahoo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; subtyping:01 escapes:01 ocaml:01 translating:01 syntax:01 camlp:01 syntax:01 translated:01 wrote:01 typing:01 caml-list:01 functions:01 functions:01 oop:01 benjamin:01 Dario Teixeira wrote: > Hi, > >> There must be something that escapes me.... This seems to be an >> example where ocaml objects really shine because of the structural >> typing (i.e. an object is defined by the its structure): > > You are right. I was probably too fixated on the OOP way of doing this, > translating record fields into object fields and the functions acting on > records into object methods. Your solution, where record fields become object > methods and external functions act on objects that match a certain structure, > does solve the inconveniences I mentioned before. But objects are still > a somewhat heavier solution, right? Heavier in terms of efficiency, or syntax? If you mean the latter, I wonder if a camlp4 syntax extension might help ease the burden; perhaps something like: #{x=5; y=6} could be translated to: object method x = 5 method y = 6 end and then you could benefit from a lightweight syntax and still get the static type checking. Dave