Crosscut

Daily Note - 2025-06-17

Hey, I'm Hanno! These are my daily notes on Crosscut, the programming language I'm creating. If you have any questions, comments, or feedback, please get in touch!

Let's imagine an alternative version of Rust, one where traits are structural instead of nominal. So every type that matches the definition of a given trait, could be used as an implementation of that trait. We wouldn't need to mention that trait by name, in the implementation of any type.

The only place where we would still need to mention the trait, is where we want to use it. Like that function in my example from two days ago. Here it is again:

fn my_fn(value: impl Format) -> String {
    // body omitted for brevity
}

And if that's the only place where we need to name the trait, then we could just as well define it right there. The trait could be anonymous:

fn my_fn(value: impl trait { fn format(self) -> String; }) -> String {
    // body omitted for brevity
}

And again, that is not new. TypeScript allows that, for example, in the form of object types.