From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA19165 for caml-redistribution@pauillac.inria.fr; Wed, 3 Nov 1999 21:44:51 +0100 (MET) Resent-Message-Id: <199911032044.VAA19165@pauillac.inria.fr> Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id EAA26152 for ; Sat, 30 Oct 1999 04:41:51 +0200 (MET DST) Received: from nef.ens.fr (nef.ens.fr [129.199.96.12]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id EAA26887 for ; Sat, 30 Oct 1999 04:41:50 +0200 (MET DST) Received: from clipper.ens.fr (clipper-gw.ens.fr [129.199.1.22]) by nef.ens.fr (8.9.3/beig-1.0) with ESMTP id EAA28724 for ; Sat, 30 Oct 1999 04:41:49 +0200 (MET DST) Received: from soling.ens.fr (bonnard@soling [129.199.129.15]) by clipper.ens.fr (8.9.2/jb-1.1) id EAA06184 for ; Sat, 30 Oct 1999 04:41:48 +0200 (MET DST) Received: from (bonnard@localhost) by soling.ens.fr (8.9.0/jb-1.1) Message-ID: <19991030044139.30767@soling.ens.fr> Date: Sat, 30 Oct 1999 04:41:39 +0200 From: Valentin Bonnard To: caml-list@inria.fr Subject: =?iso-8859-1?Q?Problème_d'oubli_dans_un_module_=5BA_problem_with_modul?= =?iso-8859-1?Q?es=5D?= Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Mailer: Mutt 0.88 Resent-From: weis@pauillac.inria.fr Resent-Date: Wed, 3 Nov 1999 21:44:51 +0100 Resent-To: caml-redistribution@pauillac.inria.fr Avec les objets, je peux faire ceci: [ With objects, I can do this: ] # class vide = object end and foo = object method get = 3 end;; class vide : object end class foo : object method get : int end Je crée un objet avec une méthode get: [ I create an object with a method called get: ] # let x = new foo;; val x : foo = J'oublie get: [ I forget ``get'': ] # let y = (x :> vide);; val y : vide = Je vérifie que get n'est plus là: [ And ``get'' isn't there anymore: ] # y#get;; This expression has type vide It has no method get J'utilise get quand même: [ I can still use ``get'': ] # let z = Obj.magic y;; val z : '_a = # print_int (z#get);; 3- : unit = () [ And it works, I understand that it is guarantied to work. ] Maintenant, les modules. [ Now, I will try to do the same thing with modules. ] # module type vide = sig end;; module type vide = sig end Je crée un module avec get: [ I create a module with a member called ``get'': ] # module Foo = struct let get = 3 end;; module Foo : sig val get : int end J'oublie get: [ Again, I forget the ``get'' member: ] # module Y = (Foo: vide);; module Y : vide Je vérifie que get n'est plus là: [ I can't access the forgotten member: ] # Y.get;; Unbound value Y.get Comment utiliser get quand même ? [ Now, how can I use ``get'' ? ] # (Obj.magic Y: sig val get : int end).get;; Syntax error Je voudrais récupérer get. Cette question vient d'un problème réel. [ I'd like to access the forgotten get member. In case you are wondering, yes, this need arises from a real problem. ] -- Valentin Bonnard