Skip to content

Interface implementation #18

@Spydr06

Description

@Spydr06

Draft on how interfaces will be implemented:

import "std.csp";

type Foo: interface {
    fn foo(self: &Foo): i32
};

type Bar: struct {
    x: i32
};

# how to implement Foo for Bar?

fn main(): i32 {
    let bar = Bar::{0};
    (&bar: &Foo).foo();

    <- 0;
}

The main question is: how should the syntax for implementing Foo for Bar look like?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions