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=1.0 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_WHOIS 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 E62CCBC69 for ; Thu, 18 Oct 2007 19:05:42 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAALUvF0fOvjGvoWdsb2JhbACOTQIBAQIFBAYJCAEXgSc X-IronPort-AV: E=Sophos;i="4.21,296,1188770400"; d="scan'208";a="3221915" Received: from web54605.mail.re2.yahoo.com ([206.190.49.175]) by mail1-smtp-roc.national.inria.fr with SMTP; 18 Oct 2007 19:05:42 +0200 Received: (qmail 33539 invoked by uid 60001); 18 Oct 2007 17:05:40 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=aFJPtRUOlFoifWnuji/ph7i1z6PCuAaq95Ok/jkfHV3WiIJaGMrBaHgDGllwQqYLo1/ONqR7Noj2L2xpvIAVsnNdOi+F60A+ZPota+FqgGXZyaISew+L1bziqQ9/Rq4b7VxiQqA1R8w3eHGsHBlbzFEVndCqNfzVevg08IeAzxY=; X-YMail-OSG: tUCpDM4VM1lPTFyHltK6IFzFOvhUOB_77d35w5vQxFH8UEpCjxlzIJwvmixBxzNoEU7mpp1v.mopxwK7h29FrLX59rF9aNgeTxGfXigC4c8XE8MNYfAz_Y.U5IghfKXnhno_ZCGqQJn7Vw4sp4ZSRM6zgA-- Received: from [82.155.125.49] by web54605.mail.re2.yahoo.com via HTTP; Thu, 18 Oct 2007 18:05:40 BST Date: Thu, 18 Oct 2007 18:05:40 +0100 (BST) From: Dario Teixeira Subject: Re: [Caml-list] Smells like duck-typing To: Brian Hurt Cc: caml-list@yquem.inria.fr In-Reply-To: <47178D1E.5050409@janestcapital.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <824282.32870.qm@web54605.mail.re2.yahoo.com> X-Spam: no; 0.00; semantics:01 cheers:01 invoke:01 caml-list:01 defined:02 inheritance:03 languages:03 let:03 let:03 root:04 types:05 problem:05 definition:07 title:90 object:09 > 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? Hi, Well, that's only a problem if you insist in thinking in terms of inheritance. Remember that the semantics of marble-carving are NOT "all that works on full_story should also work on blurb_story", but the other way around. Also, imagine you were to add the "get_body" method to the root "story" class. The type system in Marble-Caml is smart enough to tell you that since the blurb_story carved out the "body" field, then it must also carve out methods that use it. Aren't imaginary languages wonderfull?... :-) (In addition, note that in any real world situation, it wouldn't make any sense for the user to want to invoke get_body on a blurb object -- after all, by definition blurbs have no body). Cheers, Dario ___________________________________________________________ Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now. http://uk.answers.yahoo.com/