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.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 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 7DC0ABC69 for ; Thu, 18 Oct 2007 18:43:12 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAN4pF0dCm3xr/2dsb2JhbACQMg X-IronPort-AV: E=Sophos;i="4.21,296,1188770400"; d="scan'208";a="3218708" Received: from janestcapital.com (HELO smtp.janestcapital.com) ([66.155.124.107]) by mail1-smtp-roc.national.inria.fr with ESMTP; 18 Oct 2007 18:43:11 +0200 Received: from [172.25.129.161] [38.96.172.125] by janestcapital.com with ESMTP (SMTPD-9.10) id AD1E0898; Thu, 18 Oct 2007 12:43:10 -0400 Message-ID: <47178D1E.5050409@janestcapital.com> Date: Thu, 18 Oct 2007 12:43:10 -0400 From: Brian Hurt User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dario Teixeira Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Smells like duck-typing References: <939878.37106.qm@web54604.mail.re2.yahoo.com> In-Reply-To: <939878.37106.qm@web54604.mail.re2.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; marble:98 marble:98 wrote:01 caml-list:01 int:01 defined:02 defined:02 chunk:02 string:02 string:02 suggestion:03 inheritance:03 inheritance:03 let:03 let:03 Dario Teixeira wrote: >Hi, > >(This is a collective reply to all the issues that were raised by my >previous message; sorry if I don't answer each message individually). > >I made the early "reverse inheritance" suggestion somewhat facetiously, >but judging from the replies, there was a certain amount of confusion >about what I meant. > >I'll try to describe what I have in mind. I'll do it by modelling >the problem in an imaginary OCaml-derived language that features >"reverse inheritance". Please read on: > > >The "story" class is one that is fully defined. Think of it as a raw >block of marble from which the non-important pieces can be carved out. >To avoid confusion, let's call a class of this kind a "marble-class": > >marble-class story (id, title, intro, body) = >object > method id: int = id > method title: string = title > method intro: string = intro > method body: string = body >end > >Now, a "full_story" is one that is also fully defined. Taking as starting >point the "story" block-class previously defined, you don't need to carve >out anything to obtain a full_story: > >marble-class full_story (id, title, intro, body) = >object > carves story (id, title, intro, body) >end > > >However, a "blurb_story" does introduce changes: it can be formed by >taking the original story as a starting point, and removing the "body" >chunk of marble. Note that I am using some new keywords: carves, removes, >and CARVED: > >marble-class blurb_story (id, title, intro) = >object > carves story (id, title, intro, CARVED) > removes method body >end > > >Similarly, a "fresh_story" is a story without the "id" field: > >marble-class fresh_story (title, intro, body) >object > carves story (CARVED, title, intro, body) > removes method id >end > > > So now you've defined full_story, blurb_story, and fresh_story as types. Now, I write: let get_body (story: full_story) = story#get_body;; let my_blurb = new blurb_story(id, "A Title", "An Intro");; let my_body = get_body my_blurb;; what happens? Brian