Re: What databases have taught me

From: Dmitry A. Kazakov <mailbox_at_dmitry-kazakov.de>
Date: Sat, 1 Jul 2006 00:09:39 +0200
Message-ID: <1c048n90qpbs6.2xwk9uwbv2qa.dlg_at_40tude.net>


On 30 Jun 2006 12:56:13 -0700, Keith H Duggar wrote:

> Dmitry A. Kazakov wrote:

>> Marshall wrote:
>> Side note: in a strongly typed language "extension" of an
>> operation can be accomplished only through an "extension"
>> of the type (actually a class of). This happens by adding
>> a new type to the class, so that the operation extension
>> be defined on that new type.
>>
>>> I'm not familiar with the term "predicate dispatch" but
>>> as I noted above, pattern matching is roughly the
>>> flipside of OO's subtyping polymorphism.
>>
>> True. It does not add any safety, not even a feeling of.

>
> You know, there seems to be lots of jargon criss-cross here.
> For example, since type = class then "adding a new type to
> the class" is a senseless statement.

Because it is not =:

Class is a set of types derived from the same base type:

   Class T = { Ti | Ti <: T }

these types are called members of the class. The base type is called the root of the class.

The type of the class mimics a closure of above. It pretends to have values of all types in the set, or to all these types at once.

This type is distinct from any in the set. Its values are not the values of the types above. The values of this type (T"Class) are polymorphic:

   Dom (T"Class) = { (t, v) | t in Class T, v in Dom (t) }

I.e. it is a set of pairs. The first element is a type from the class [=type tag]. The second element is a value of that type.

[ An example: in C++ class X denotes: type and class and the type of the class (which has lots of nasty consequences). The type tag in C++ is a vtab pointer. Specific values v and polymorphic ones (t,v) have the same representation. This is why C++ has no int'Class, there is no free place in it. This is also why C++ is single dispatch and can re-dispatch. ]

Methods, dispatching operations, virtual functions whatever names they have are defined on the class. The body of such function is implemented by individual overrides. Dispatch happens when a polymorphic object is passed to such a method, which causes selection of the target override according to the type tag of the object. This selection is called dispatch.

> And as we can see
> "predicate dispatch" is at least unfamiliar to some and
> "pattern matching" can mean /many/ things.
>
> What would be great is if along with flying jargon around
> you all provided /examples/ (in some psuedocode) of what
> you are trying to describe.

See above. This is a sketch of the formalization of OO I referred to.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
Received on Sat Jul 01 2006 - 00:09:39 CEST

Original text of this message