Xref: utzoo comp.lang.misc:7099 comp.object:2911 comp.lang.eiffel:1467 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!apple!agate!stanford.edu!leland.Stanford.EDU!elaine2.Stanford.EDU!hoelzle From: hoelzle@elaine2.Stanford.EDU (urs hoelzle) Newsgroups: comp.lang.misc,comp.object,comp.lang.eiffel Subject: Re: CHALLENGE: typing and reusability Message-ID: <1991Mar27.061929.28406@leland.Stanford.EDU> Date: 27 Mar 91 06:19:29 GMT References: <1991Mar22.210725.29448@neon.Stanford.EDU> <3090@enea.se> Sender: news@leland.Stanford.EDU (Mr News) Organization: Stanford University - AIR Lines: 44 In <3090@enea.se> sommar@enea.se (Erland Sommarskog) writes: > As the first proponent of dynamic typing, Urs Hoelzle > (hoelzle@neon.Stanford.EDU) gives us a concrete example > where langauges with static typing are said to bite the dust. Just to set the record straight: I do not claim that dynamically-typed languages are always better for all kinds of problems, or any such thing. I posted this example because someone claimed that static typing does not affect reusability, and I just couldn't let this stand unchallenged. > class FOO_DISPLAY_LIST(T -> SUPER) > -- () is easier to read than [] on my screen. > export repeat LINKED_LIST, do_foo, display > inherit LINKED_LIST -- or whichever list that's appropriate > feature > -- define iterators that call foo and display > end > > We can now declare: > ListA : FOO_DISPLAY_LIST(A); > ListB : FOO_DISPLAY_LIST(B); > ListC : FOO_DISPLAY_LIST(SUPER); This is nice, but it only addresses the trivial part of my example. The hard part comes when you actually try to use the lists you defined. I don't have an Eiffel system to try this, but I don't think this will type-check. >listC := listA.concatenate(listB); // make a new list containing As and Bs > >someProc(listC); // do the "foo thing" to the list > >listC.do(display); // display all elements of the list (Remember that "someProc" is supposed to already exist, and its parameter is a FOO_LIST, not a FOO_DISPLAY_LIST.) For all your other comments see my other posting (response to a C++ example). -Urs -- ------------------------------------------------------------------------------ Urs Hoelzle hoelzle@cs.stanford.EDU Center for Integrated Systems, CIS 42, Stanford University, Stanford, CA 94305