logoalt Hacker News

wavemodeyesterday at 10:50 PM1 replyview on HN

One thing I dislike about the syntax of Tomo is that the return type is annotated inside the parentheses. e.g. this function returns Text:

    func greeting(name:Text, add_exclamation:Bool -> Text)

Replies

bruciferyesterday at 11:48 PM

OP here, it might be a bit unfamiliar at first, but I think Tomo's syntax makes the type annotations really nice for functions that return functions: `func make_adder(amount:Int -> func(x:Int -> Int))` instead of `func make_adder(amount:Int) -> func(x:Int) -> Int`. The latter can be easily mistaken for a function that returns an integer since it starts with `func make_adder(` and ends with `) -> Int`, especially if you're not well-versed in currying. With Tomo's syntax, it's easier to see at a glance that `make_adder` returns a function without the need to add extra grouping parentheses for clarity. IMO, Tomo's syntax is also a bit more readable for lambdas when the return type is specified: `func(x:Int -> Int) x+1` vs `func(x:Int) -> Int x+1`