how to setup this heirarchy

S

shahbazc

I'm need a subsystem of 'functors' in a program I am writing. Since I
am doing this project, mainly, as a learning experience, I'm not going
to use Apache's functors (they also have more functionality that I
need).

So I have the following structure, and I'm having a hard time coming up
with an elegant heirarchy:

interface IVariable{IType evaulate();}
interface IType{IType evaluate();}
interface IFunction{IType evaulate(); addParam(IVariable);}
interface IPredicateFunction{BooleanType evaluate();
addParam(IVariable);}
interface ICombinatorFunction{BooleanType
evaulate();addParam(BooleanType);}
class BooleanType extends IType{BooleanType evaulate();}

Basically I want to pass around my set of types or functions. Each has
an evaulate() function so I can call that function and expect a result
of type IType. IType will return itself (or a polymorphic version of it
self) and IFunction will evaulate itself and return the result as
IType.

I thought I could have a function implement both IFunction and
IPredicateFunction and implement function 'BooleanType evaulate();'
which would also cover IFunction since BooleanType is a subtype of
IType...but I guess I can't use narrower return types in method sigs.
class SomeFunction implements IFunction,IPredicateFunction{BooleanType
evaluate(){...}; addParam(IVariable v){...};}

I thought of using generics, but not sure if they will improve matters.
So any ideas on how best to organize these interfaces into (preferably
a single) heirarchy?

Falcon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top