On 16/07/14 23:21, Jonas Maebe wrote:
On 16/07/14 21:19, Sven Barth wrote:
I'm not that sure whether using the same syntax is a good idea... people
want to have Delphi compatible anonymous functions which are basically
reference counted interfaces instead of records...

Well, the block variable that's passed around is also a pointer. The
record it points to can either be non-reference counted (in case it's a
block for a global procedure/function, since those don't have context
and hence can be reused for all instances) or reference counted. In the
latter case, they start life on the stack, and are copied to the heap if
necessary by the run time based on the copy/release calls that are
made). In a sense, they behave a bit like an interface.

One definite incompatibility between blocks-based and other "reference to" functions right now is that the former do not accept types that are reference counted in Pascal. The reason is that when those blocks would be called from another language, the reference count wouldn't be updated. While other languages don't know about e.g. FPC-implemented ansistrings, some people would definitely start passing such ansistrings as pointers to outside code, so that this code could then pass it in again to a block invoked as a callback.


Jonas
_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to