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.2 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE 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 451F1BC69 for ; Wed, 17 Oct 2007 18:52:26 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAANrZFUfLENaMnmdsb2JhbACOTgIBAQcEBhEY X-IronPort-AV: E=Sophos;i="4.21,290,1188770400"; d="scan'208";a="3158679" Received: from ipmail01.adl2.internode.on.net ([203.16.214.140]) by mail2-smtp-roc.national.inria.fr with ESMTP; 17 Oct 2007 18:52:24 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAANrZFUd5LCRs/2dsb2JhbAAM X-IronPort-AV: E=Sophos;i="4.21,290,1188743400"; d="scan'208";a="212661043" Received: from ppp121-44-36-108.lns10.syd7.internode.on.net (HELO [192.168.1.201]) ([121.44.36.108]) by ipmail01.adl2.internode.on.net with ESMTP; 18 Oct 2007 02:22:22 +0930 Subject: Re: [Caml-list] Smells like duck-typing From: skaller To: Dario Teixeira Cc: Daniel =?ISO-8859-1?Q?B=FCnzli?= , caml-list@yquem.inria.fr In-Reply-To: <788147.33893.qm@web54602.mail.re2.yahoo.com> References: <788147.33893.qm@web54602.mail.re2.yahoo.com> Content-Type: text/plain Date: Thu, 18 Oct 2007 02:52:20 +1000 Message-Id: <1192639940.10798.2.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; 0100,:01 sourceforge:01 wrote:01 rec:01 caml-list:01 data:02 essentially:02 match:02 string:02 string:02 objects:02 let:03 raise:03 dynamic:03 dynamic:03 On Wed, 2007-10-17 at 16:13 +0100, Dario Teixeira wrote: > > I would use something weaker, and I wouldn't use objects > > either. To me, this is essentially a dynamic scenario, > > so the data type should be dynamic. For example: > > > > type field_t = [ > > | `Title of string > > | `Intro of string > > | `Body of string > > | `Field of string * string > > ] > > > > type story_t = field_t list > > > > Hi, > > Interesting idea, but how would you access the fields in a convenient > manner? let rec get_title ls = match ls with | `Title s :: _ -> s | _ ::t -> get_title t | [] -> raise Not_found (* sucks.. *) -- John Skaller Felix, successor to C++: http://felix.sf.net