From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: function as first class object
Date: Mon, 15 Jan 2018 18:37:32 +0100
Date: 2018-01-15T18:37:32+01:00 [thread overview]
Message-ID: <p3iot1$1989$1@gioia.aioe.org> (raw)
In-Reply-To: dbd6d6ee-10b7-4cef-b7a6-e75205b9965e@googlegroups.com
On 2018-01-15 17:20, Mehdi Saada wrote:
> I'm thinking only of a limited form.
> Like writing:
> type FILTER_TYPE is access function (S: in STRING) return STRING;
> FILTER: FILTER_TYPE := ( TO_BASIC( TO_LOWER ) )'Access
> Not sure of the syntax though. Could it done one way or another ?
Yes. You declare an abstract filter type with a primitive operation
Apply. Then you create handles to that type with the same interface.
The purpose of the exercise is to escape limitness of the target types.
You derive an object from the abstract filter type with the function as
the discriminant of. The implementation of Apply calls to the
discriminant function.
You derive an object from the abstract filter type with a container of
handles. The implementation of Apply calls Apply for the elements of the
list passing the result as an argument to the next.
You define a compose operation, e.g. "+" on handles that creates an
object with two handles in the list taken from the arguments and returns
a handle to it.
That is.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2018-01-15 17:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-15 16:20 function as first class object Mehdi Saada
2018-01-15 17:37 ` Dmitry A. Kazakov [this message]
2018-01-15 17:46 ` Mehdi Saada
2018-01-15 17:50 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox