Re:Free Pascal compiler now supports dynamic packages
by wk_end on Sunday October 18, 2026 @07:31PM
(#50146580)
All OP is asking for is the ability to declare variables at first use instead of at the top of a function. You don't need closures or anything that'd inhibit C compatibility for this - C itself has supported this since C99. It's fairly simple if you're willing to give up single-pass compilation, which (I think?) FPC already has.
Re:Free Pascal compiler now supports dynamic packages
by trashface on Sunday October 18, 2026 @10:17PM
(#50147604)
Could probably just get the source and have an LLM vibe code that, for personal use seems fine.
Re:Free Pascal compiler now supports dynamic packages
by vintagedave on Monday October 19, 2026 @07:42AM
(#50151161)
I think OP is talking about inline variables (in Delphi terminology), ie writing a var or const where you use it instead of in a var or const block at the top of the method.
Anonymous methods are the ones that are implemented via an interfaced object. It is a bit odd and I wish they had chosen something more ABI-compatible with a C++ functor, since it would have made mapping between the two easier IMO.
I have a test branch of the Oxygene compiler -- no idea if we'll merge it in, we make syntax experiments regularly -- where all callables are assignment-compatible. In Delphi terms this means assigning an anon method to an event handler would work, but equally for us, lambdas, blocks, and more. The idea is somewhat C++-like in terms of std::function and std::bind but with simple syntax in that you write it and it works: if it can be called, it can be applied where any callable method-like expectation exists.
Though I do very much appreciate C#, with its lambda functions, expression trees, and especially the tooling, Free Pascal and Lazarus exist as a happy compromise between those things and native code integration, where working with C libraries like libcairo, libxml2, libssl, libsdl, and opengl are much easier and a pleasure to work with when using Free Pascal, and conversely are more difficult to wrangle when using C# or Java.