[fpc-devel] Functors
Blaise at blaise.ru
Blaise at blaise.ru
Mon Dec 27 00:18:14 CET 2021
On 27.12.2021 0:57, Martin Frb via fpc-devel wrote:
>> writeln( aC(33) );
>> aC('hello');
> the above examples are probably intended to show the syntax. But not indented to show any useful application?
The test you quoted demonstrates what is already possible, syntactically and semantically, using a simple patch I have extracted from my implementation of Closures. The "missing parts" list recognises that a better syntax for the operator declaration is needed, and suggests the keyword OPERATOR. A better syntax was the major point of the discussion thus far.
> then what in "functor" is a new feature (rather than shortcut)
>
> a functor is meant to be ref-counted
A functor is a non-routine entity ("object") that behaves like a routine. Meaning: you can invoke it like a routine (via an overloaded "operator ()"), you can store it like a routine (in a method pointer). That is all, it is quite a simple feature, really. RECORD, OBJECT, CLASS, and INTERFACE instances are supported as such entities. With these entities, you manage memory as usual.
--
βþ
More information about the fpc-devel
mailing list