[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dynamic vs. static typing



"Matt Hellige" <matt@immute.net> wrote in message
20031121132417.K25194@metro.immute.net">news:20031121132417.K25194@metro.immute.net...
> [Neelakantan Krishnaswami <neelk@gs3106.sp.cs.cmu.edu>]
> > Peter van Rooijen writes:
> > > From: "Joe Marshall" <jrm@ccs.neu.edu>
> > > > 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?
>
> Matt

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
['sword', 'rock']
> eat: room.'rock'
Can't eat rock!
> eat: room.'sword'
Are you really sure you want to do that? :)

 -- Mike