[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dynamic vs. static typing
"Matt Hellige" <email@example.com> wrote in message
> [Neelakantan Krishnaswami <firstname.lastname@example.org>]
> > Peter van Rooijen writes:
> > > From: "Joe Marshall" <email@example.com>
> > > > I was just pointing out that lists of unknown objects are
> > > > interesting in and of themselves.
> > >
> > > It seems to me that they are as interesting as natural numbers.
> > >
> > > After all, that's what they are, right?
> > Not quite: you can reverse a list without knowing its contents.
> > Reynold's abstraction theorem says that parametrically polymorphic
> > functions do not perform any operations on the values at polymorphic
> > type. Phillip Wadler wrote a paper on how you can turn this around and
> > use it to deduce specific theorems about functions without actually
> > having to do a proof. For example, because reverse has the type
> > reverse: List a -> List a
> > we know that it can't modify the values of the list. It can only
> > delete, copy, or permute the cons cells, all without looking at the
> > inside of its contents.
> > See: <http://citeseer.nj.nec.com/wadler89theorems.html>
> This is both true and useful. But what's the point of permuting the
> elements of a list if no other part of the program can or will ever
> inspect the values? In fact, how could one even determine that such a
> permutation had been done?
There are far more uses for heterogenious lists when the focus in not on the
program, but on semantics: AI, MUDs, etc.
> room objects = [Sword new, Rock new]
> room listObjects
> eat: room.'rock'
Can't eat rock!
> eat: room.'sword'
Are you really sure you want to do that? :)