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,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 822FABC6B for ; Thu, 18 Oct 2007 17:02:36 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAALYSF0fRVYC8kmdsb2JhbACOTQIBAQcEBBMWgSk X-IronPort-AV: E=Sophos;i="4.21,295,1188770400"; d="scan'208";a="18220376" Received: from fk-out-0910.google.com ([209.85.128.188]) by mail4-smtp-sop.national.inria.fr with ESMTP; 18 Oct 2007 17:02:36 +0200 Received: by fk-out-0910.google.com with SMTP id b27so198359fka for ; Thu, 18 Oct 2007 08:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; bh=eoHWgusRg0gYK48+ObjHz3jGL6KmW56rZYTfZeu9Dtc=; b=JbKPw3BnZTmp1SEC/X/cJwS+J38DwPPZtX/nhwIuwiYz4fJn61lw4DNG0ngMQuu7eTHKrlnl/dLWXLMOu31mrx/6ieFyrBNgMu7mNCpc5GxqG8tv6WlpyalXEjudpKnfPuZUAOhMUPsxfsg/nj4HlEGoS0KdW9MtXgHOhzxNpb4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=diRCymCVJmCGYqCXfe33D6jXjtUWy5x5XhnSRYOtILNHHVxAnGtb02Q3vVWwXlrhCGcpQVJfj2PO+uYOIU0xFXV7hKCJmdf9tlUvkDubFD+25tzm2DigYo0m3FwU/nqOjiM2LTOu+JbyxVLMlfqIiJgrD1pb56PlIFuqqcwp+Zo= Received: by 10.82.178.11 with SMTP id a11mr1289765buf.1192719753777; Thu, 18 Oct 2007 08:02:33 -0700 (PDT) Received: from ?192.168.0.5? ( [87.88.165.197]) by mx.google.com with ESMTPS id y6sm2182960mug.2007.10.18.08.02.31 (version=SSLv3 cipher=RC4-MD5); Thu, 18 Oct 2007 08:02:32 -0700 (PDT) Message-ID: <47177585.6030208@lix.polytechnique.fr> Date: Thu, 18 Oct 2007 17:02:29 +0200 From: Arnaud Spiwack User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Smells like duck-typing References: <377673.31302.qm@web54602.mail.re2.yahoo.com> <47176B4A.5000807@janestcapital.com> <47176DB6.7090700@lix.polytechnique.fr> <471771A7.3010402@janestcapital.com> In-Reply-To: <471771A7.3010402@janestcapital.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: Arnaud Spiwack X-Spam: no; 0.00; lix:01 supertype:01 subtype:01 subtype:01 subtyping:01 subtyping:01 ocaml:01 ocaml's:01 polymorphism:01 supertype:01 haskell-like:01 imho:01 arnaud:01 arnaud:01 caml-list:01 > > Saying that A is a supertype of B is the equivelent of saying B is a > subtype of A. Same relation, different direction. In OO lingo, how > they say "B is a subtype of A" is that "B inherits from (is a subclass > of) A". That's not true. That's how you say it in *some* Object Oriented languages. Inheritance is a tool which allows you to derive another object from another one. You like it to be a subtype though, it usually is rather difficult to build a sound inheritance system where it can break subtyping anyway (though if you implement the self-type specialization in the inheritance but not in the subtyping, it might work, but it's unlikely to be what you want to do). Thus, let's say that "inheritance is one way to obtain a subtype B out of a type A" (the only way in languages such as Java). In OCaml for instance, object types exist and subtyping between them. Classes are a mere way to produce values of these types, and to provide an inheritance mechanism (which is compatible with subtyping). > > I will note that Ocaml's row-level polymorphism allows you to invent > new supertypes of a given subtype as needed (a real nice feature, > IMHO). But what he's asking for is fundamentally nonsensical. You don't invent them, they exist. I can't agree to dismiss this suggestion without further thought. It might end up being non-sensical, maybe not. It merely suggests a way, to derive new values, whose type happen to be a supertype of the original one. Why not ? It may be considered to the Haskell-like "derive" feature, and such. It is just a way to build new values out of known one. Arnaud Spiwack