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

Re: dynamic vs. static typing

On 2003-11-20T09:26:49-0500, Joe Marshall wrote:
> Surely you can think of *something* other than simple destructuring!
> What about `property lists' (alternating key and values) or
> `association lists' (list of key/value pairs), or simple sets?  All of
> these are interesting sorts of objects, they may be heterogeneous, and
> useful operations exist (assoc or member, for example) that do not
> need to know the type of the object contained in the list.

> What about representing a matrix as a list of lists?  Transposing such
> a thing doesn't require knowledge of the types involved, but it can be
> useful.

Let me make my previous claim a bit more concrete: any function that
you can write, that can take as input a list of elements, where the
only thing you know you can do to every element is to pass it around,
and that always returns without error a boolean as output, must always
return the same boolean for all input values of the same "shape".  In
other words, replacing every element with an empty data structure would
never change the output of such a function.  (I use "boolean" here
to model observations on the result of a program.  Another type like
"character" or "integer" would do fine.)

The intuition that I am trying to get at is, -some- part of your program
needs to assume -something- about the interface supported by your list
elements in order for the program overall to observably operate on the
list and its elements.  You can very well reverse a list, throw out
every third element, concatenate the string keys in an association list,
etc., but in the end if you can't assume anything about the elements,
then you might as well not keep the elements around at all.

> Things like the `wedge product' from exterior algebra (thanks
> to Greg Pettyjohn for showing me this) don't require the object types
> to be known.

The wedge product (or for that matter if I understand correctly, the
function that takes a list of values and computes their product) doesn't
require knowing the object types, but it does require knowing that the
object types are "the same" in that it requires knowing a multiplication
function that takes two elements and produces a new one.


Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
"Sendmail may be safely run set-userid to root." -Sendmail Install Guide

Attachment: signature.asc
Description: Digital signature