Re: Clean Object Class Design -- What is it?

From: Graham Perkins <gperkins_at_dmu.ac.uk>
Date: Mon, 09 Jul 2001 17:08:40 +0100
Message-ID: <3B49D708.1E998B2B_at_dmu.ac.uk>


Rico wrote:
>
> "peter_douglass" <baisly_at_gis.net> wrote in message
> > >"Set-level operations" have nothing to do with updating information.
> > >"Set-level operations" are: union, intersection, difference, etc.
> > > There's no "update" in there.
> >
> > insert(x,S) = union (S, {x})
> > remove(x,S) = difference(S, {x})
> > update(x,y,S) = insert(y, remove(x,S) )
>
> Ouch, completely obvious and I missed it. Relational algebra 101 and I
> blew it utterly. I stand corrected.

No, you were correct the first time. The "union" and "difference" operators shown above are not the basic set operations of set union and set difference that you are familiar with from set theory. They are just syntactic sugar for the procedural notions of insert, remove, and update.

The union and difference set operations with which we are familiar from set theory are dyadic *functions*. The operation

   union(A,B)
defines a set in terms of the sets A and B. It does not "change" A or B in any way, since set notation like the rest of regular
mathematics is referentially transparent.


In fact, even in procedural programming terms,

> > insert(x,S) = union (S, {x])
> > remove(x,S) = difference(S, {x})
> > update(x,y,S) = insert(y, remove(x,S) )

is not helpful. Suppose, for example, "insert" is a function which adds three copies of its item to its set and removes any occurrence of "99". Finally, it returns the value "fishcakes" as its result.

Suppose also that "union" is a function that places its item in its set and returns the value "fishcakes".

The first equality above holds, with very little usefulness!

No. We cannot co-opt genuine set operations into procedural programming directly. It can be done, but usually with denotational or axiomatic semantics, eg

M [[ insert(x,S) ]] s = lambda(i) if i=S then union(x,s(S)) else s(S)

or

 .. { insert(x,S) } S = union(x,S')

-- 
http://www.mk.dmu.ac.uk/~gperkins/
Received on Mon Jul 09 2001 - 18:08:40 CEST

Original text of this message