[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dynamic vs. static typing
Matt Hellige <firstname.lastname@example.org> writes:
> [Joe Marshall <email@example.com>]
>> There is some value to having a list where *no* part of your program
>> assumes *anything* about the interface.
> I can't understand what you mean here. I'm not being provocative,
> facetious, or intentionally obtuse. I really honestly can't think of a
> single example. Could you provide one?
Let's suppose that for some reason we need to determine if some
property is unique to a collection of items. Let us assume that we
have some mechanism by which we can map a function over a set of
elements and collect a list of the non-null results. So we could map
a function that extracts the property over a collection of items,
collecting the answers into a list and then check to see if we got
more than one element. We might not know what type F computed, but we
do know that only one object satisfies it.
This is obviously strained. We'd probably just apply F to the
elements and check to see that it fails on all but one. But perhaps
the uniqueness criteria is part of some module A that operates on
lists, and the mapping function F is part of some module B, and the
collection comes from some other module C. We need not be aware that
some list is being constructed somewhere and its length will be
checked elsewhere and the contents won't be consumed anywhere.