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.4 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 3F1B2BC69 for ; Fri, 5 Oct 2007 13:08:32 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAO63BUfZDAshnmdsb2JhbACOOQIBAQcEBhEY X-IronPort-AV: E=Sophos;i="4.21,235,1188770400"; d="scan'208";a="2415298" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 05 Oct 2007 13:08:32 +0200 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l95B8VrR029275 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 5 Oct 2007 13:08:32 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAO63BUfZDAshnmdsb2JhbACOOQIBAQcEBhEY X-IronPort-AV: E=Sophos;i="4.21,235,1188770400"; d="scan'208";a="2415296" Received: from smtp002.mail.ukl.yahoo.com ([217.12.11.33]) by mail2-smtp-roc.national.inria.fr with SMTP; 05 Oct 2007 13:08:31 +0200 Received: (qmail 18818 invoked from network); 5 Oct 2007 11:08:30 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.fr; h=Received:X-YMail-OSG:In-Reply-To:References:Mime-Version:Content-Type:Message-Id:Cc:Content-Transfer-Encoding:From:Subject:Date:To:X-Mailer; b=fCUCrtbUvoWC6dhfYwyww911nKY6N0XB68ynwkKtvFoe1QhCiCqBID7kenr5JCVKSd6TuRkRrT/NyzKt3kZlXPZKpetlmqPQXgfi+LluFQoWvAxP8i67HggBcbUyky+Hk42yGd+IWSNzS0Xw+YlQClb5/P9pMLoCr4634Xr1bq8= ; Received: from unknown (HELO ?192.168.0.10?) (vincent.aravantinos@82.229.199.66 with plain) by smtp002.mail.ukl.yahoo.com with SMTP; 5 Oct 2007 11:08:30 -0000 X-YMail-OSG: iJyq_U0VM1noFKXiRIPobOP51olRJg5AjSe69SuJ0xHU1_QO85vtBjkmNwt_2z8n6cRvGDYh1w-- In-Reply-To: <28fa90930710050108k34cff56dge24e1e9c4a01f9bd@mail.gmail.com> References: <28fa90930710050048p3d6f4e8cs8e13d0fe49d296f2@mail.gmail.com> <4705EF58.3040605@bik-gmbh.de> <28fa90930710050108k34cff56dge24e1e9c4a01f9bd@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed Message-Id: Cc: "Inria Ocaml Mailing List" Content-Transfer-Encoding: quoted-printable From: Vincent Aravantinos Subject: Re: [Caml-list] Why can't I call a function over a subclass? Date: Fri, 5 Oct 2007 13:08:27 +0200 To: Luca de Alfaro X-Mailer: Apple Mail (2.752.2) X-Miltered: at discorde with ID 47061B2F.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; superclass:01 ocaml:01 runtime:01 runtime:01 checker:01 annotations:01 compiler:01 ocaml:01 compiler:01 cheers:01 stays:98 wrote:01 typing:01 typing:01 caml-list:01 Le 5 oct. 07 =E0 10:08, Luca de Alfaro a =E9crit : > I don't understand this. I thought the whole idea of oo =20 > programming was that you could use a subclass in place of a =20 > superclass... > > I also thought that the strict typing of Ocaml was there to avoid =20 > runtime errors, but if so, why does it complain in this situation, =20 > when no runtime error can possibly happen? > > It seems to me that the idea of oo programming is broken for no =20 > good reason... - This is absurd in an oo context. Here, the main paradigm is not oo. =20= It is simply strongly typed. So if you write that a function expects =20 a particular type, this function should be applied with this =20 particular type and nothing else. *You* wrote this so you claimed for =20= it. You want more generality ? Then let the type checker do its job as =20 Pietro said. *The default behaviour is not to write any type info.* =20 If you stay with this you get the standard oo behaviour. Annotations are there to give more info to the compiler in case it =20 does infer what you have in mind. - Strict typing of Ocaml is not to avoid runtime errors. It simply =20 stays that if two types expected to be the same differ, we suppose =20 *the program does not match what the programmer has in mind*. As a =20 little side-effect, this can avoid runtime errors :) If you keep this idea of "what the programmer has in mind", in this =20 particular case you said to the compiler with your type annotation =20 that what you had in mind was that the function only takes a r. What =20 you said to the compiler was not what you had in mind. And I insist again: the default behaviour (don't anotate) gives you =20 what you would expect. Cheers, Vincent=