Skip to content

support unboxed, uniquely typed closures #8622

Closed
@thestinger

Description

@thestinger

It would need to be made obvious that these are generic functions/structs, because they won't be interchangeable.

fn foo<T: fn(int, int)>(x: T, y: int) { x(5, y) }

Every closure would have either a unique type (like C++ closures) or at least a type based on the environment. A stack closure would start off as a bare moveable fn(...) implementation able to be converted to boxed &fn(...), ~fn(...) or Rc<fn(...)> objects.

An unboxed closure would just be static dispatch without a function pointer. As with traits, you would choose between static/dynamic dispatch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationA-frontendArea: Compiler frontend (errors, parsing and HIR)A-type-systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions