Skip to content

Implement Function Level generics (81#)#82

Closed
CoopsDaemon wants to merge 4 commits intoOttrlang:mainfrom
CoopsDaemon:main
Closed

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

Conversation

@CoopsDaemon
Copy link
Copy Markdown
Contributor

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.

@CoopsDaemon CoopsDaemon closed this Mar 4, 2026
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