Skip to content

fpc-unleashed/freepascal

 
 

Repository files navigation

🚀 FPC Unleashed

FPC Unleashed is a community-driven fork of Free Pascal, focused on pushing the language forward with modern, expressive, and practical features that have not (yet) been accepted into the official compiler.

🌟 Key Features

✨ Statement Expressions - {$modeswitch StatementExpressions} - #1037

Allows using control flow statements like if, case, and try as expressions, enabling a more functional and concise coding style.

Code examples:

s := if n > 0 then 'foo' else 'bar';
s := case x of
  1..3: 'in 1-3 range';
  6..9: 'in 6-9 range';
else 'out of range';
function canfail: string;
begin
  if random(2) = 1 then raise Exception.Create('exception');
  result := 'hello world';
end;
// ...
s := try canfail() except 'failed';

✨ Array Equality - {$modeswitch ArrayEquality} - #829

Adds support for = and <> comparisons between arrays when ArrayOperators is enabled.

✨ Unleashed Mode - {$mode unleashed} or -Munleashed

A modern Pascal mode based on ObjFPC but with powerful enhancements enabled by default.

The following modeswitches are enabled automatically in this mode:

  • StatementExpressions - Use if, case, and try as expressions.
  • AnonymousFunctions - Anonymous procedures and functions.
  • FunctionReferences - Function pointers that capture context.
  • AdvancedRecords - Records with methods, properties, and operators.
  • ArrayOperators and ArrayEquality - Direct array comparisons.
  • AnsiStrings - Uses AnsiString by default.
  • UnderscoreIsSeparator - Allows underscores in numbers (1_000_000).
  • DuplicateNames - Allows reusing identifiers in limited scopes.

Note

Placing {$mode unleashed} directly in your source file may interfere with IDE autocompletion. It's recommended to enable the mode via -Munleashed in the Project's Custom Options instead.

📦 Installation

Option 1: Fresh install (FPC + Lazarus via fpcupdeluxe)

  1. Download fpcupdeluxe and run it once to generate the fpcup.ini file.
  2. Edit fpcup.ini and add the following under [ALIASfpcURL]:
[ALIASfpcURL]
fpc-unleashed.git=https://github.com/fpc-unleashed/freepascal.git
  1. Reopen fpcupdeluxe, uncheck GitLab, and select fpc-unleashed.git as your FPC version.
  2. Choose any Lazarus version you like.

fpcupdeluxe

  1. Click Install/update FPC+Lazarus.
  2. Optionally install cross-compilers via the Cross tab.

Option 2: Upgrade existing fpcupdeluxe setup

  1. Make sure your existing FPC+Lazarus was installed with fpcupdeluxe.
  2. In your installation directory, delete or rename the fpcsrc folder.
  3. Clone the FPC Unleashed repo into the fpcsrc directory.
git clone https://github.com/fpc-unleashed/freepascal.git fpcsrc
  1. In fpcupdeluxe, go to Setup+, check FPC/Laz rebuild only, and confirm.
  2. Click Only FPC to rebuild the compiler and RTL.
  3. Optionally install cross-compilers via the Cross tab.

🤝 Contributing

We welcome bold ideas, experimental features, and contributions that challenge the status quo of the Pascal language.

FPC Unleashed is a playground for innovation. If you've ever built a language feature that was "too weird" or "not standard enough" for upstream - this is where it belongs.

🛠 What you can contribute

  • 🧪 New language constructs and modeswitches
  • 🔧 Compiler enhancements or RTL improvements
  • 🧹 Cleanup and refactoring of legacy code
  • 🐞 Bugfixes related to unleashed features

Packages

No packages published

Languages

  • Pascal 87.1%
  • Makefile 9.6%
  • Assembly 1.9%
  • WebIDL 0.5%
  • C++ 0.2%
  • Pawn 0.2%
  • Other 0.5%