From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 187B57FD90 for ; Fri, 13 Jan 2017 10:09:07 +0100 (CET) X-IronPort-AV: E=Sophos;i="5.33,221,1477954800"; d="scan'208";a="209004016" Received: from dt-64014.paris.inria.fr (HELO [128.93.64.14]) ([128.93.64.14]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 13 Jan 2017 10:09:06 +0100 To: caml users From: =?UTF-8?Q?Fran=c3=a7ois_Pottier?= Message-ID: <99968acc-c9f1-273f-d983-4a286a2e8068@inria.fr> Date: Fri, 13 Jan 2017 10:09:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: [Caml-list] How to indicate that I am overriding an inherited virtual method? Dear OCaml users, Is there an OCaml equivalent of Java's @Override keyword, which allows indicating that a method definition is intended to override an inherited (virtual or concrete) method? As far as I can see, in OCaml, the "method!" form works for inherited concrete methods: class base = object method foo: string = "uh?" end class child = object inherit base method! foo = "ha!" (* OK *) end but does not work for inherited virtual methods: class virtual base = object method virtual foo: string end class child = object inherit base method! foo = "ha!" (* Error: The method `foo' has no previous definition *) end Is this intentional? This is too bad. I seem to be forced to use "method" instead of "method!". Therefore, I cannot indicate my intent, and if I mistype the name "foo" in the definition of the child class, the compiler cannot catch this mistake. (Well, in this case, it can, as the child class is not declared virtual.) -- François Pottier francois.pottier@inria.fr http://gallium.inria.fr/~fpottier/