Skip to content

Add support for binding a method off an impl #435

Closed
@lkuper

Description

@lkuper

Make it legal to do the following:

obj foo() {
    fn add5(n: int) -> int {
        ret n + 5;
    }
}

fn add5(n: int) -> int {
    ret n + 5;
}

fn main() {
    let fiveplusseven = bind add5(7);
    log_err fiveplusseven();

    // Can't do this currently
    let my_foo = foo();
    let fiveplusseven_too = bind my_foo.add5(7);
    log_err fiveplusseven_too();
}

This feature would make it possible to reify methods as standalone functions. (I haven't thought through all the implications of this; I suppose the resulting function would have to capture the object in its scope.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frontendArea: Compiler frontend (errors, parsing and HIR)A-type-systemArea: Type system

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions