comp.lang.ada
 help / color / mirror / Atom feed
From: Jacob Sparre Andersen <sparre@nbi.dk>
Subject: Re: Defining a binary operator between function access types: Is it possible?
Date: 16 Oct 2008 17:14:36 +0200
Date: 2008-10-16T17:14:36+02:00	[thread overview]
Message-ID: <871vygd12b.fsf@nbi.dk> (raw)
In-Reply-To: fed9902a-28f0-4e70-a427-4773b20aae47@p49g2000hsd.googlegroups.com

soychangoman@gmail.com writes:

> I'm trying to define a binary operator between function access types
> that returns the access to the function that is the binary operator
> acting on both functions.

You can't do that quite like that.

The first idea which springs to mind for solving this kind of problem
is to make a hack using tagged types ...

   type Abstract_Binary_Operation is abstract tagged null record;
   function Operate (O    : Abstract_Binary_Operation;
                     L, R : Real) return Real is abstract;

   type Composed_Addition (FL, FR : access function (X : Real) return Real) is
     new Abstract_Binary_Operation with null record;
   function Operate (O    : Composed_Addition;
                     L, R : Real) return Real is
   begin
      return O.FL (L) + O.FR (R);
   end Operate;

Just a wild thought!  Not tested!

Greetings,

Jacob
-- 
People in cars cause accidents. Accidents in cars cause people.



  parent reply	other threads:[~2008-10-16 15:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-16 13:34 Defining a binary operator between function access types: Is it possible? soychangoman
2008-10-16 14:26 ` Dmitry A. Kazakov
2008-10-16 14:29 ` Adam Beneschan
2008-10-16 22:18   ` Robert A Duff
2008-10-16 15:14 ` Jacob Sparre Andersen [this message]
2008-10-17  7:10 ` Defining a binary operator between function access types: Is it anon
2008-10-21  6:46 ` Defining a binary operator between function access types: Is it possible? Ivan Levashew
2008-10-21 13:17   ` soychangoman
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox