3 ms·
Trying to understand this: is the lambda symbol defined somewhere globally? How can they just use it Willy nilly as a generic Stand-in for a spread parameter t
by dclowd9901 4y ago
Trying to understand this: is the lambda symbol defined somewhere globally? How can they just use it Willy nilly as a generic Stand-in for a spread parameter type?
- upzylon 4y agoIt's just an identifier like any other defined in types.ts: https://github.com/MathisBullinger/froebel/blob/main/types.ts#L1 https://github.com/MathisBullinger/froebel/blob/main/types.t... It's defined as type λ<TA extends any[] = any[], TR = any> = (...args: TA) => TR; meaning λ is just any function and λ<[number], string> would be the type of a function that takes a number as its only argument and returns a string.
- dclowd9901 4y agoOk that’s what I thought, thanks!
- WorldMaker 4y agoJS (and TS thereby) allows arbitrary unicode in identifiers (variable names, class names, [TS] type names). The lambda symbol is just acting as the name of a type parameter instead of something more ASCII usual like `T` or `F`. There's a lot of interesting discussions around it as some math libraries like to use math symbols and greek letters and sometimes even emoji as variable/class names in JS and other developers have a gut reaction that they do not like it.