Delf

Delf under construction

Delphi with a modern, functional-influenced type system, transpiling to plain Delphi.

A Delf file is Delphi with additions of syntax and code-correctness: sum types and pattern matching in place of nil and sentinel values, tuples, lambdas with inferred types, no implicit conversions, exhaustive cases. A transpiler, delfc, turns it into readable, standard Delphi that a Delphi programmer could have written by hand and can step through in the debugger.

WriteLn('passed: ', Scores.Filter(IsPass).Map(.ToString).Join(', '));

// the plain Delphi it stands for, with Shown(N) answering N.ToString
WriteLn('passed: ', TArrays.Join(
                        TArrays.Map<Integer, string>(
                            TArrays.Filter<Integer>(Scores, IsPass), Shown), ', '));

Rename any Delphi file to .delf and nothing changes but some extra checks. delfc is tested on over 18,000 distinct files of real Delphi, from Delphi's own RTL and VCL and 123 open-source repositories. The design filter is better safety without red tape: a safety rule that makes the writer repeat themselves is a sign the syntax is missing something.

Videos

Articles

Slides

More

The approach, what works today, what's planned and the evidence are in the DelfPascal repository: its experiments, the corpus delfc is tested on, its performance against hand-written Delphi and C++, and worked examples.