4 ms·
Is having a dedicated fn keyword necessary? I mean, what’s the fundamental difference between a func and a fn ?
by curist 3y ago
Is having a dedicated fn keyword necessary? I mean, what’s the fundamental difference between a func and a fn ?
- hongbo_zhang 3y agoNot strictly necessary, we are not decided on it. For func the annotation is required, while fn does not need any type annotation
- darkest_ruby 3y agoI would strongly recommend to only go with one syntax, and not differentiate between regular functions and lambda statement
- ledauphin 3y agoI disagree - allowing for type inference on the closures will make for a much more pleasant language, whereas requiring type annotations on top level functions makes sense for lots of reasons.
- troupo 3y ago> allowing for type inference on the closures You can still have your type inference without forcing the unnecessary requirement that local functions be `fn` while top functions be `func`.
- ledauphin 3y agoagreed, but there's still differentiation in syntax, and I was responding to someone asking for no differentiation.
- andrewcobby 3y agoI agree with this, I'm designing a similar language and have gone with this approach. Same syntax for all functions, but top-level functions require explicit type annotations (purely for documentation/sanity more so than a technical requirement).