Skip to content

Implement generics #154

Open
Open
@certik

Description

@certik

We need to allow writing generic functions (templates) and template constraints.

One idea that we can explore is to also support something like: #152 (comment):

>>> def str(val: i32 | f64):
...   # "isinstance" type guard
...   if isinstance(val, i32):
...     # type of `val` is narrowed to `i32`
...     return str_int(val)
...   elif isinstance(val, f64):
...     # else, type of `val` is narrowed to `f64`
...     return str_float(val)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions