<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/07/17972e65a4fa6e1be37544c22613850e"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-16T09:21:43"
  subject="Re: [Caml-list] Recovering masked methods"
  prev="2002/07/f49c5a97e201b0f6ea5977beb5930c17"
  next="2002/07/73c0fee4b3e84b859b7eba0407a4f4f4"
  prev-in-thread="2002/07/dc0f73cee705120e47f611b302d2229c"
  next-in-thread="2002/07/4bbe8c44332ba5a3150f66f671c75eaa"
  prev-thread="2002/07/f588263f2499215c76c4696e61086612"
  next-thread="2002/07/ca2a3e0a12658384bdc94c4ad62eb59b"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Recovering masked methods">
<msg 
  url="2002/07/2fe55408b32aa0c8bbfe694c2fc4d83a"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-15T23:06:46"
  subject="[Caml-list] Recovering masked methods">
<msg 
  url="2002/07/dc0f73cee705120e47f611b302d2229c"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2002-07-16T01:15:48"
  subject="Re: [Caml-list] Recovering masked methods">
<msg 
  url="2002/07/17972e65a4fa6e1be37544c22613850e"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-16T09:21:43"
  subject="Re: [Caml-list] Recovering masked methods">
<msg 
  url="2002/07/4bbe8c44332ba5a3150f66f671c75eaa"
  from="Laurent Vibert &lt;lvibert@i...&gt;"
  author="Laurent Vibert"
  date="2002-07-16T09:48:33"
  subject="Re: [Caml-list] Recovering masked methods">
<msg 
  url="2002/07/cdb48831ef99b8f2f30bb2c41cfffc21"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-16T10:03:53"
  subject="Re: [Caml-list] Recovering masked methods">
</msg>
<msg 
  url="2002/07/09f0c8681907e8992348940da99cad75"
  from="Johan Baltié &lt;johan.baltie@w...&gt;"
  author="Johan Baltié"
  date="2002-07-16T10:08:20"
  subject="Re: [Caml-list] Recovering masked methods">
</msg>
</msg>
<msg 
  url="2002/07/a4e7111559c35cc347dce02da761c6d4"
  from="Johan Baltié &lt;johan.baltie@w...&gt;"
  author="Johan Baltié"
  date="2002-07-16T09:59:43"
  subject="Re: [Caml-list] Recovering masked methods">
<msg 
  url="2002/07/d8d8048f18fde67a30d15fff45a35cd0"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-16T11:01:06"
  subject="Re: [Caml-list] Recovering masked methods (with CamlP4?)">
<msg 
  url="2002/11/016e4090efb8e82cad8d8d8247cc1f70"
  from="Eray Ozkural &lt;erayo@c...&gt;"
  author="Eray Ozkural"
  date="2002-11-12T19:47:58"
  subject="Re: [Caml-list] Recovering masked methods (with CamlP4?)">
</msg>
<msg 
  url="2002/07/b59eca1b7e5590da95546ae14fabfec6"
  from="Johan Baltié &lt;johan.baltie@w...&gt;"
  author="Johan Baltié"
  date="2002-07-16T11:32:44"
  subject="Re: [Caml-list] Recovering masked methods (with CamlP4?)">
<msg 
  url="2002/07/079c1f77e6e6ffdeb3b3e90ab408aff5"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-16T12:45:21"
  subject="Re: [Caml-list] Recovering masked methods (with CamlP4?)">
</msg>
</msg>
<msg 
  url="2002/07/3de0fe9da97cf529cecbfd91303a3bd0"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-07-16T12:26:56"
  subject="Re: [Caml-list] Recovering masked methods (with CamlP4?)">
<msg 
  url="2002/07/3010b130a14bbcce52ad13d282b7bc8e"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-16T12:47:43"
  subject="Re: [Caml-list] Recovering masked methods (with CamlP4?)">
<msg 
  url="2002/07/b81da613b70144f0000c305c48fda6a9"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-07-17T09:26:40"
  subject="Re: [Caml-list] Recovering masked methods (with CamlP4?)">
</msg>
</msg>
</msg>
<msg 
  url="2002/07/e7cc3630ab3efd751fb7ab23ee8cd246"
  from="John Prevost &lt;j.prevost@c...&gt;"
  author="John Prevost"
  date="2002-07-16T13:25:28"
  subject="Re: [Caml-list] Recovering masked methods (with CamlP4?)">
<msg 
  url="2002/07/64938492e1b530128ae42eb730af62b2"
  from="John Prevost &lt;j.prevost@c...&gt;"
  author="John Prevost"
  date="2002-07-16T13:28:39"
  subject="Re: [Caml-list] Recovering masked methods (with CamlP4?)">
</msg>
<msg 
  url="2002/07/22bfb44ade56966015ca1e7b98b02394"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-16T13:59:43"
  subject="Re: [Caml-list] Recovering masked methods (with CamlP4?)">
<msg 
  url="2002/07/4b34e2322a3787668e7cc44878eaae57"
  from="Johan Baltié &lt;johan.baltie@w...&gt;"
  author="Johan Baltié"
  date="2002-07-16T14:15:50"
  subject="Re: [Caml-list] Recovering masked methods (with CamlP4?)">
<msg 
  url="2002/07/429a6ddd7c1da1d3259de9ec4b1a2c13"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-16T14:22:35"
  subject="Re: [Caml-list] Recovering masked methods (with CamlP4?)">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/07/bdc2038f2220ce701049a9e8d6a5abc9"
  from="John Prevost &lt;j.prevost@c...&gt;"
  author="John Prevost"
  date="2002-07-16T10:38:38"
  subject="Re: [Caml-list] Recovering masked methods">
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
Jacques Garrigue wrote:
&gt; From: Alessandro Baretta &lt;alex@baretta.com&gt;

&gt;&gt;Now I would like to define a third class, inheriting from b. 
&gt;&gt;  I need this class to be able to access the definition of 
&gt;&gt;method m from class a, otherwise I would have to use "copy &amp; 
&gt;&gt;paste", which is contrary to my programmer's ethics.
&gt; 
&gt; 
&gt; You don't need to be too ethical about that.
&gt; What's so great about strong typing, is that it makes copy-paste work!

:-)

&gt; And you can always write
&gt; 
&gt; let a_m = 1
&gt; class a = ... method m = a_m ..

This is not viable. The toy code I have shown here does not 
provide any real functionality, but in the real application 
you have to imagine the following situation:


class a =
object (self)
   method m = &lt;some generally useful stuff
   method m1 = &lt;other generally useful stuff&gt;
   ...
   method mn = &lt;other generally useful stuff&gt;
end

class b =
object (self)
   inherit a as super_a
   method m = &lt;specific stuff&gt;; super_a # m
   method m1 = &lt;specific stuff&gt;; super_a # m1
   ...
   method mn = &lt;specific stuff&gt;; super_a # mn
end


class small_variant_of_b =
object (self)
   inherit b as super_b
   method m = super_b # super_a # m
(* All the specific stuff in method m is not needed *)
(* Yet, all other methods must be inherited from b  *)
end


Without the above notation, I could only think of copying 
the code of method m out of class a and pasting it into 
class small_variant_of_b, but this makes maintainance a 
mess. And I am working on a production class system. No 
good. However, I did not consider the following idea, which 
is not bad indeed. In the absence of the notation I 
described above, or of an equivalent one, I'll do as you 
propose here.

&gt; If you want to stay indide the object, you can also save the old
&gt; method to a private one:
&gt; 
&gt; class b = ... method private a_m = super_a#m ...
&gt; 
&gt; 
&gt;&gt;Ideally, I would like to write
&gt;&gt;
&gt;&gt;class c =
&gt;&gt;object (self)
&gt;&gt;   inherit b as super_b
&gt;&gt;
&gt;&gt;   method m =
&gt;&gt;     (* some_stuff *)
&gt;&gt;     super_b # super_a # m
&gt;&gt;end
&gt;&gt;
&gt;&gt;Presently, this is not allowed. Is there any specific reason 
&gt;&gt;for this? Could such a feature be implemented in the future?
&gt; 
&gt; 
&gt; OK, you want something like C++'s qualified calls?
&gt; There's no project to do that. Methods do not exist independently of
&gt; their class.
&gt; Another approach would be to provide views, as described by Jerome
&gt; Vouillon. That is, an object could keep some extra sets of methods in
&gt; an abstract way. But there's not project to implement that either.

You are getting too technical for me. I'm not a compiler 
guru, only a user, so I'm not sure what could or should be 
done. Let me propose a syntax which might make things clearer.

class a =
object
   ...
end

class b =
object
   inherit a
   ...
end

class c =
object
   inherit a as super_a through b as super_b { through 
&lt;class&gt; as &lt;identifier&gt; }*
...
end

Let me call this syntax "explicit inheritance hierarchy 
relation". This syntax is only viable if we assume that 
extending a working class library never requires to *insert* 
a class between two classes in a relation of inheritance. 
Such extensions would break the above code. I don't believe 
this limitation would have any real impact on the the 
usability of the language or of this extension.

&gt; Yet, it's not even clear such an ancestor call would make sense in
&gt; general.
&gt; Could you give some more compelling example requiring such a feature?

I a method m in class b can call a method x in super_a 
(which is class a), and a method m' in class b' can call
a method m in super_b (which is class b), then, by 
transitity, a method in class b' can call a method x in 
super_a. All we need is some syntactic sugar to make this 
happen "automagically". But I would not rely on CamlP4 for 
this: the syntax extension would not have a local impact, so 
we need help from the compiler.

Let me know what you think.

Alex

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

