A good syntax for generics

Actually this is funnier as a multiple choice.

Tbh, <T> is great, I wish we didn't need those symbols for anything else.

Show thread

@virtulis my favourite is the C++ oopsie, where >> is an operator and you can't (or couldn't, when I was using C++) write <M<A>> without a space. 🙂

But I think both Rust and Typescript handle template style polymorphism quite ergonomically!

@jonn Except for the part where you have to write Type<T,> in .tsx :blobcatupsidedown:

Follow

@virtulis my hot take is that it's the jsx problem! If we went from xml to json to yaml or toml, how come we still use xml for composing react components? 😭

@jonn I'm not sure what I wrote is required but one case it certainly is if you're a weirdo and like writing stuff like

const fn = <A> (a: A) => ...

Cause that's obviously an opening JSX tag. Adding a comma helps disambiguate (and pisses off ESLint).

The reason I meh'd at Haskell stuff is because I want this to be implicit unless actually needed (as in TS).

So not as worried about definitions as being able to write let rgb = image.convert<RGB>() or let rgb: Image<RGB> = image.convert() or let rgb: Image = image.convert(); rgb.at(0,0).red = 0; (etc)

Which kind of calls for a specific syntax construct that is never expected and almost always allowed.

Sign in to participate in the conversation
Doma Social

Mastodon server of https://doma.dev.