Hasty Briefsbeta

Show HN: I implemented generics in my programming language

5 days ago
  • #type-parameters
  • #compile-time
  • #generics
  • Generic functions in Axe use type parameters to adapt behavior to multiple concrete types.
  • Type-specific logic is selected at compile time using `when` clauses.
  • Example: `some_function[T]` behaves differently for `float`, `i32`, and other types.
  • Nested contexts allow multiple type parameters to interact, as in `list_contains[T, T2]`.
  • `IntList` and `StringList` are specialized structures used with generic functions.
  • Generic functions can return type-dependent values while maintaining a single return type, e.g., `maybe_double[T]`.
  • Generic functions can call other generic functions with automatic type inference, e.g., `process_values[T]` calling `add_or_concat[T]`.
  • Axe's generics provide expressive, type-driven specialization without runtime overhead.