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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 03346BC6B for ; Wed, 17 Oct 2007 16:59:08 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAE7AFUfOvjGtoWdsb2JhbACOTgIBAQIFBAYJCAEX X-IronPort-AV: E=Sophos;i="4.21,289,1188770400"; d="scan'208";a="3153664" Received: from web54603.mail.re2.yahoo.com ([206.190.49.173]) by mail2-smtp-roc.national.inria.fr with SMTP; 17 Oct 2007 16:59:07 +0200 Received: (qmail 31289 invoked by uid 60001); 17 Oct 2007 14:59:06 -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=ecotF6kiyPge/zhcw3bjoz8JOEHpVmbpFs9vKXXCwBy5pWvRq8nOPQtOdcaqpRVoB6ZRY1Iw0ExcX7x/3mFtpqsqnjsjIpUtKMiG+a4Vo5va1wvSh6fjp4exdhyz/Cvx9M3MC4G2i8r5xvVwhLkZyuZEL2NyIOePfPosBJHmyQM=; X-YMail-OSG: 7G4p_O8VM1myFS2GjxvsZi7lDi7MPx_SRlSang3c4w0wywnd9sLHxYcsszPuXDtmY9fhog9gVCyBDnyxmHhZn1W9f.kE0.9kgJbJXZ0oKcr3e1.IDSL6tKbFBJXxeB7Mcrjx2corrEobtvcfyu2kuhOcJQ-- Received: from [82.155.120.49] by web54603.mail.re2.yahoo.com via HTTP; Wed, 17 Oct 2007 15:59:06 BST Date: Wed, 17 Oct 2007 15:59:06 +0100 (BST) From: Dario Teixeira Subject: Re: [Caml-list] Smells like duck-typing To: Chris King Cc: caml-list@yquem.inria.fr In-Reply-To: <875c7e070710170733h205fbe54ube172e969da65871@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <387117.31000.qm@web54603.mail.re2.yahoo.com> X-Spam: no; 0.00; subtyping:01 ocaml:01 hackery:01 functors:01 semantics:01 functor:01 cheers:01 ditch:98 avoids:01 caml-list:01 functions:01 modules:02 parameter:02 objects:02 module:03 Hi, > Why not have different object types for each of the story types? e.g. Yes, other people have suggested the same, and while not a perfect solution (because of the reduplication of fields), the object subtyping feature of OCaml (the bit that smells a lot like duck-typing...) is powerful enough to avoid the code duplication in functions such as print_metadata. More important, it avoids the ugly hackery with option types. > If on the other hand you wanted to ditch objects entirely, you could > do a similar thing using modules and functors. E.g.: That is actually an interesting approach. If I'm not mistaken, the semantics for the parameter to a functor is "a module whose signature contains at least this", which is again similar to duck-typing... Cheers, Dario ___________________________________________________________ Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now. http://uk.answers.yahoo.com/