Skip to content

Implement generics #154

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):

>>>defstr(val: i32|f64):
... # "isinstance" type guard
... ifisinstance(val, i32):
... # type of `val` is narrowed to `i32`
... returnstr_int(val)
... elifisinstance(val, f64):
... # else, type of `val` is narrowed to `f64`
... returnstr_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