3 ms·
> Traits are hard to extend after the fact, and you can't break them into smaller parts in a backwards-compatible way. > No way of defining abstract types that
by elcritch 4y ago
> Traits are hard to extend after the fact, and you can't break them into smaller parts in a backwards-compatible way.
> No way of defining abstract types that conform to a given interface. You can use traits, but these do not support abstract associated types, and require a Self type.
This is definitely one of the main grievances I have with Rust. Overall, Rust can be a productive language but it's frustratingly limited when it comes to advanced types or really anything compile time. I read something a while back that made sense to me, to paraphrase "Rust solves problems by brute force".
The syntax for annotations on structs are also really distracting to me as well.
(edited spelling)
- gpm 4y ago> They syntax for annotations on structs are also really distracting to me as well. I really like annotations on structs/struct fields, but I've never seen a syntax for it that felt quite right. The ones that I've seen and come to mind are rust's: #[annotation goes here, always tokenized and usually strictly parsed according to some custom-ish dsl] go's: "let's just use a string, parsing is often questionable" and kotlin/scala/...'s @SingleIdentHere(Maybe, With, Arguments) I'm curious if people have other examples, and/or a preference for one.
- neilv 4y agoScheme: (my-syntax-identifier-goes-here (we do not annotate) (we transform syntax))
- elcritch 4y agoAnnotations are very useful, but they're pretty much ugly regardless of the language. Though I like the sibling comment's Scheme version where it's postfixed. I've also come to appreciate Nim's sorta post-name annotation syntax since I can quickly read the name and type at the ends: type MyComponent = object position {.editable, animatable.}: Vector3 alpha {.editRange: [0.0..1.0], animatable.}: float32 I was pondering if languages could provide CSS like annotation. Like #annotate: MyComponent.position { editable }