Docs/Reference/Syntax Migration
Syntax Migration
Moving code from the original pf/pv/pc keywords to the v1.0 standard-keyword syntax.
~2 min read
On this page
What changed
The v1.0 specification (2026-08-26) replaced Fid’s original unique keywords with standard, universally understood ones:
| Old | New | Meaning |
|---|---|---|
pf | fn | Function declaration |
pv | val | Immutable variable |
pv mut | var | Mutable variable |
pc | const | Compile-time constant |
ret | return | Return statement |
ty | type | Type alias |
pm | (removed) | Use var x: T; |
cap and use are unchanged. They are short, distinct, and part of Fid’s identity.
Why
- Learning curve: new users no longer learn six unfamiliar keywords before writing a line.
- AI familiarity: models are trained on billions of lines using
fn,let-style bindings, andreturn. - Self-hosting: the compiler will be written in Fid; standard keywords make its source readable to every contributor.
- Zero cost: keyword spelling has no effect on compile speed, binary size, or runtime.
Migrating a codebase
Replacement order matters, since pv mut must be handled before pv:
find . -name "*.fd" -exec sed -i \
-e 's/\bpv mut\b/var/g' \
-e 's/\bpv\b/val/g' \
-e 's/\bpf\b/fn/g' \
-e 's/\bpc\b/const/g' \
-e 's/\bret\b/return/g' \
-e 's/\bty\b/type/g' \
-e 's/\bpm\b/var/g' \
{} \;Edge cases
| Old syntax | New syntax | Notes |
|---|---|---|
pv mut x = 10; | var x = 10; | mut is dropped |
pm x: i32; | var x: i32; | Uninitialized mutable |
pf(x: i64) => x * 2 | fn(x: i64) => x * 2 | Closures; parameters need types |
async pf foo() | async fn foo() | Modifiers unchanged |
extern "C" pf foo() | extern "C" fn foo() | FFI |
use core with { IO } | (unchanged) | Capability grants keep with |
cap Drawable { } | (unchanged) | cap keeps its name |
What does not change
References (&x, &mut x), the ? operator, :: paths, -> and => arrows, ranges (.., ..=), f-strings, struct/enum/impl/match syntax, and every operator are all identical. #[...] attributes still parse, and fid ignores them: use @ annotations.
Good to know: the script also renames any identifier, string or comment that is exactly
pv,pf,pc,ret,tyorpm(a variable namedtybecomestype). Review the diff before you commit. The\bword boundaries andsed -ineed GNU sed.