Skip to content

Implement Function Level generics (81#)#82

Open
LqauzDev wants to merge 4 commits intoOttrlang:mainfrom
LqauzDev:main
Open

Implement Function Level generics (81#)#82
LqauzDev wants to merge 4 commits intoOttrlang:mainfrom
LqauzDev:main

Conversation

@LqauzDev
Copy link
Contributor

@LqauzDev LqauzDev commented Feb 3, 2026

Note: this is a cleaned up reopened version of #81

Summary
This adds parsing and AST support for function generics (fn name<T, U>(...)), includes a small runnable example, and updates docs to present generics as a shipped language feature. It’s the parser/AST and docs half of the work; typechecking and codegen follow-ups are tracked separately.

Files changed

nodes.rs

grammar.rs
examples/generics.ot
TUTORIALS.md
EXAMPLES.md
FFI_GUIDE.md
ROADMAP.md
LANGUAGE_SPEC.md

Parser accepts optional <T, U> generic parameter lists on fn declarations.
AST node carries the generic parameter names.
Example examples/generics.ot demonstrates struct and function generics.
Docs updated to describe generics as available and to explain FFI behavior for generic instantiations.
Why
Users can now write generic functions in source and find accurate examples and docs in-tree. This is necessary before wiring up typechecker inference and codegen for generics.

Notes and constraints

Runtime and ABI unchanged. This PR is syntactic + docs.
Typechecker inference, bounds, and monomorphization are follow-up work.
If you prefer to gate the feature behind a feature flag, we can add that in a follow-up.

was tested on WSL and Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants