# Re: The wisdom of the object mentors (Was: Searching OO Associations with RDBMS Persistence Models)

Date: Thu, 1 Jun 2006 20:38:42 +0200

Message-ID: <1e5fof7hw2l4w$.17a0yf1ukn1oi$.dlg_at_40tude.net>

On 1 Jun 2006 10:19:45 -0700, Mikito Harakiri wrote:

>> On 1 Jun 2006 09:08:23 -0700, Mikito Harakiri wrote: >>> Function is a set of ordered pairs such that a certain condition is >>> met. Where is "object" in this definition? >> >> I said - an object corresponding to function. Function is the value of that >> object. If 2 can be a value, why a function cannot be?

*>*

> Well, it is easy to understand what the domain of numbers is and what

*> operations are among them. So I can implement the Integer class. Can*

*> you write a definition of Function class?*

These are three questions in one. There is a sufficient difference between:

- Predefined types [of functions]
- User-defined types of
- User-defined classes of

To have objects you need only 1. When a function is declared the compiler can easily create an anonymous type for it. That would be 1. If you want a type of functions 2. that shouldn't be a big problem either. There is little difference between that and pointers to functions. You can find them in practically any language.

Class of functions is more interesting, but if the signature is fixed it imposes no problem. As a guess, a polymorphic functional objects should multiple dispatch on the tuple: (function, argument lists, result lists).

Class of all functions, that might be really difficult, if possible. There are as well many interesting questions about classes of polymorphic functions, inheritance from functions, relationships between functions on related types. For example is the type of functions on a subtype a subtype of the type of functions on the base type? Without an elaborated and consistent type theory they are difficult to answer.

Operations on functions (subprograms):

Map : f x x1 x x2 x ... x xN -> y1 x y2 x ... x yN

- : f1 x f2 -> Boolean 4. Copy (for marshaling, closures etc)

:= : f -> f

- : f1 x f2 x sum x prod x inv -> sum (prod (f(x), g(inv (x))) 6. Extension

and so on

>> But that is rather trivial and uninteresting.

*>*

> Well, it's hardly trivial for numbers, why it suddenly becomes trivial

*> for functions?*

Because in this particular case function is a value and values are outside the language scope. Somewhere in the application domain exists 2. So there does sine. You don't care what they are. You only need some object to represent them. Let the bit pattern 0x1 represent 2 and 0x2 do sine. End of story.

>> The question was actually about subprograms >> rather than mathematical functions. They can be objects.

*>*

> So can you write a code that supports your otherwise meaningless

*> gibberish?*

Don't you see any difference between mathematical constructs and programming language objects?

-- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.deReceived on Thu Jun 01 2006 - 20:38:42 CEST