Known Limitations Related to Anonymous Methods

Top  Previous  Next

New features since Delphi 7 > Anonymous Methods > Known Limitations Related to Anonymous Methods

1 Automatic Boxing of Captured Variables Is Not Implemented

 

In Delphi, variables captured by anonymous methods are boxed automatically and remain valid as long as a closure referencing them exists.

 

The current C++ translation does not automatically box captured variables.

 

2 Lifetime Extension of Captured Variables Is Not Guaranteed

 

Returning a lambda capturing local variables by reference results in undefined behavior.

 

 

3 Multiple Anonymous Methods Sharing One Captured Variable Are Not Safely Translated

 

Shared captured state is not automatically boxed.

 

 

4 Distinct Delphi Types with Identical Signatures Are Not Always Fully Preserved

 

Depending on translation mode, some types may collapse to identical C++ types.

 

 

5 Problems Caused by Naive Lambda Translation

 

Typical symptoms include:

 

unexpected numeric values
crashes when invoking callbacks
invalid capture variables

 

 



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content