"David Vallner" <david / vallner.net> wrote in message news:44EB91B4.5070805 / vallner.net... >> Sure, you can reuse a variable for very different purposes but is that >> really such an advantage? > > You don't do this. Heck, you shouldn't even reuse a variable for the same > purpose. Reusing variables tends to imply that you don't really know what > their purpose was in the first place. I don't think we disagree here. This is one thing that dynamic typing allows you to do and I'm questioning whether this is a benefit and you're saying it absolutely isn't. So, we can agree that this does not contribute to the benefits of dynamic typing... > The advantage of dynamic typing comes in working with the hairier design > patterns. It's a reduction ad extremum of a way of constraining object > behaviour - the typical members of the "expliticly" typed language group > use type / class hierarchies for this, and check against those. By "it's a reduction ad extremum of a way of constraining object behaviour" do you mean that it reduces object behaviour in an extremely non-constraining way? With statically typed languages, the behaviour of an object is defined by membership. If this variable is a member of this set, then it may have these properties. So, when a function requires that a parameter be of a certain type, it must be a member of this certain set. The use of other types that may also work in this function but are not in this set are (arbitrarily) excluded. With dynamically typed langauges, because variables (including parameters) may be of any type, parameters passed into a method will work as long as they, literally, satisfy the requirements of the method. This is much more flexable than defining arbitrary membership. It's "ad extremum" in the direction of flexability. Unfortunately, it's also flexable enough to allow you to pass a totally inappropriate parameter into a method but that's the trade off. Is it worth it? Most of us think so... In my opinion, this amounts to promoting the use of code in differing contexts (or, simply, code reuse), which is the advantage that I had stated before... > For (a very contrived) example any object that just so happens to > properly respond to the messages for arithmethical operations can be > substituted for an "integer" you only ever do arithmetics with without > the language runtime batting an eyelash. This isn't a contrived example, it's just a vague one. If you want an example you can use in the future, how about a function or method that takes a vector and a list of vectors and sees if the given vector can be expressed as a linear combination of the list of vectors. Because so many things have vector properties (real numbers, complex numbers, Cartesian vectors, matrices, real valued functions, almost anything, it seems), you can reuse this function or method with any of these types! How amazing is that?