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
-
A Brief Introduction to Delf Pascal & Zed
Delf in the Zed editor: what it adds to Delphi, and what delfc writes from it.
-
Delphi Pre-Processor Starter
Rules that check and rewrite standard Delphi, on a tree-sitter parse: the starter repository.
-
Delphi File-Mapped Debugging 🤯
The starter in the Delphi IDE: a
.dppssource built through a pre-build event, and dcc's own errors on its lines, through{$LINE}: double-click to the source, and the debugger in it. -
Delphi File Mapping Debug - Part 2
Footnotes after
end.that become XMLDoc for Help Insight, and[Derive(ToString)]on an enumeration, its generated code on the attribute's line.
Articles
- The Delf specification, version 0.1
What Delf adds to Delphi, the rules behind each choice, and the plain Delphi delfc writes for every part. Stage 1 designed; Stage 2 shaped.
- Generic type inference in Delf: inside and outside
How delfc works out a generic call's type arguments, from its arguments and from where its value goes, and when you must write one.
Slides
- Finding the start
One search, written every way Delf allows, and what delfc writes.
- The big ideas
The present as a proof of concept, then the future.
- A natural sort, idiomatically
Windows' file order as Delf code: nine versions timed, what decided the speed, and the model that states the rule.
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.