[fpc-devel] $modeswitch Closures

Blaise at blaise.ru Blaise at blaise.ru
Sat Dec 25 20:22:57 CET 2021


The attached modeswitch_closures.patch introduces {$modeswitch Closures}; it is included in {$mode Delphi}.

There is a distinction between anonymous routines (defined in-place, without a name) and closures (capture the context they are invoked with). The switch encompasses both, but goes for the shorter and catchier name.

-- 
βþ
-------------- next part --------------
# HG changeset patch
# User Blaise.ru
# Date 1640457371 -10800
#      Sat Dec 25 21:36:11 2021 +0300
+ new {$modeswitch Closures}, included in {$mode Delphi}

diff -r d880e6695537 -r 3ecaef5e9a49 globals.pas
--- a/globals.pas	Mon Dec 20 20:55:22 2021 +0300
+++ b/globals.pas	Sat Dec 25 21:36:11 2021 +0300
@@ -55,7 +55,7 @@
           m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal,m_default_ansistring,
           m_out,m_default_para,m_duplicate_names,m_hintdirective,
           m_property,m_default_inline,m_except,m_advanced_records,
-          m_array_operators,m_prefixed_attributes];
+          m_closures,m_array_operators,m_prefixed_attributes];
        delphiunicodemodeswitches = delphimodeswitches + [m_systemcodepage,m_default_unicodestring];
        fpcmodeswitches =
          [m_fpc,m_string_pchar,m_nested_comment,m_repeat_forward,
diff -r d880e6695537 -r 3ecaef5e9a49 globtype.pas
--- a/globtype.pas	Mon Dec 20 20:55:22 2021 +0300
+++ b/globtype.pas	Sat Dec 25 21:36:11 2021 +0300
@@ -520,6 +520,7 @@
                                     ansistring; similarly, char becomes unicodechar rather than ansichar }
          m_type_helpers,        { allows the declaration of "type helper" for all supported types
                                   (primitive types, records, classes, interfaces) }
+         m_closures,            { anonymous routines and closures }
          m_blocks,              { support for http://en.wikipedia.org/wiki/Blocks_(C_language_extension) }
          m_isolike_io,          { I/O as it required by an ISO compatible compiler }
          m_isolike_program_para, { program parameters as it required by an ISO compatible compiler }
@@ -712,6 +713,7 @@
          'FINALFIELDS',
          'UNICODESTRINGS',
          'TYPEHELPERS',
+         'CLOSURES',
          'CBLOCKS',
          'ISOIO',
          'ISOPROGRAMPARAS',


More information about the fpc-devel mailing list