* [Caml-list] Duplicate methods - bug or feature?
@ 2001-08-23 16:14 Paul Stodghill
2001-08-23 16:24 ` Alan Schmitt
0 siblings, 1 reply; 3+ messages in thread
From: Paul Stodghill @ 2001-08-23 16:14 UTC (permalink / raw)
To: caml-list
Is it a bug or feature that a class can contain two methods with the
same name? Thanks.
milhouse$ uname -a
CYGWIN_NT-5.0 MILHOUSE 1.3.2(0.39/3/2) 2001-05-20 23:28 i686 unknown
milhouse$ ocamlc -v
The Objective Caml compiler, version 3.02
Standard library directory: /usr/local/lib/ocaml
milhouse$
milhouse$
milhouse$ cat double_method.ml
class a =
object
method m = "a.m1"
method m = "a.m2"
end
;;
let _ =
let x = new a in
Printf.printf "x=%s\n" x#m;
()
;;
milhouse$
milhouse$
milhouse$ ocamlc -o double_method.exe double_method.ml
milhouse$ ./double_method.exe
x=a.m2
milhouse$
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Duplicate methods - bug or feature?
2001-08-23 16:14 [Caml-list] Duplicate methods - bug or feature? Paul Stodghill
@ 2001-08-23 16:24 ` Alan Schmitt
2001-08-23 16:31 ` Paul Stodghill
0 siblings, 1 reply; 3+ messages in thread
From: Alan Schmitt @ 2001-08-23 16:24 UTC (permalink / raw)
To: Paul Stodghill; +Cc: caml-list
You might consider it a feature, due to multiple inheritance. IIRC, when
a class inherits from two classes which define the same method name, the
last one wins.
Alan Schmitt
* Paul Stodghill (stodghil@cs.cornell.edu) wrote:
> Is it a bug or feature that a class can contain two methods with the
> same name? Thanks.
>
> milhouse$ uname -a
> CYGWIN_NT-5.0 MILHOUSE 1.3.2(0.39/3/2) 2001-05-20 23:28 i686 unknown
> milhouse$ ocamlc -v
> The Objective Caml compiler, version 3.02
> Standard library directory: /usr/local/lib/ocaml
> milhouse$
> milhouse$
> milhouse$ cat double_method.ml
> class a =
> object
> method m = "a.m1"
> method m = "a.m2"
> end
> ;;
>
> let _ =
> let x = new a in
> Printf.printf "x=%s\n" x#m;
> ()
> ;;
>
> milhouse$
> milhouse$
> milhouse$ ocamlc -o double_method.exe double_method.ml
> milhouse$ ./double_method.exe
> x=a.m2
> milhouse$
>
> -------------------
> Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
> To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
--
The hacker: someone who figured things out and made something cool happen.
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Duplicate methods - bug or feature?
2001-08-23 16:24 ` Alan Schmitt
@ 2001-08-23 16:31 ` Paul Stodghill
0 siblings, 0 replies; 3+ messages in thread
From: Paul Stodghill @ 2001-08-23 16:31 UTC (permalink / raw)
To: caml-list
While I understand how this is handy in the case of multiple
inheritance, I don't see how this is useful when both methods are in the
same class. I think that if duplicates methods appear in a class, then
it is very likely to be an error. At a minimum, a warning should be
issues that the first method will be ignored.
I bring this up, because I just tracked down a bug in some of my own
code that resulted from two methods with the same name existing in the
same class. It was a "cut and paste" error on my part.
Thanks.
> You might consider it a feature, due to multiple inheritance. IIRC, when
> a class inherits from two classes which define the same method name, the
> last one wins.
>
> Alan Schmitt
>
> * Paul Stodghill (stodghil@cs.cornell.edu) wrote:
> > Is it a bug or feature that a class can contain two methods with the
> > same name? Thanks.
> >
> > milhouse$ uname -a
> > CYGWIN_NT-5.0 MILHOUSE 1.3.2(0.39/3/2) 2001-05-20 23:28 i686 unknown
> > milhouse$ ocamlc -v
> > The Objective Caml compiler, version 3.02
> > Standard library directory: /usr/local/lib/ocaml
> > milhouse$
> > milhouse$
> > milhouse$ cat double_method.ml
> > class a =
> > object
> > method m = "a.m1"
> > method m = "a.m2"
> > end
> > ;;
> >
> > let _ =
> > let x = new a in
> > Printf.printf "x=%s\n" x#m;
> > ()
> > ;;
> >
> > milhouse$
> > milhouse$
> > milhouse$ ocamlc -o double_method.exe double_method.ml
> > milhouse$ ./double_method.exe
> > x=a.m2
> > milhouse$
> >
> > -------------------
> > Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
> > To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
>
>
> --
> The hacker: someone who figured things out and made something cool happen.
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-08-23 16:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-23 16:14 [Caml-list] Duplicate methods - bug or feature? Paul Stodghill
2001-08-23 16:24 ` Alan Schmitt
2001-08-23 16:31 ` Paul Stodghill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox