4 ms·
The `:` are actually doing the same thing, introducing a block (think of it like a limited function). The `/` are also the same (division), but it's true that
by floitsch 4y ago
The `:` are actually doing the same thing, introducing a block (think of it like a limited function).
The `/` are also the same (division), but it's true that we also use `/` to introduce types. For example `x/int`.
I think Toit is relatively easy to learn, but there are definitely a few things that need explaining in the beginning.
- mananaysiempre 4y agoExcuse my idle curiosity, but... slash for type ascription? How did that happen? The only precedent I can think of is Prolog’s arity annotations (and jq’s, but I suspect a direct influence there). Does this come from some chunk of programming-language lore I’m unaware of?
- krallja 4y agoIt’s also used in Elixir and Erlang for arity, but now that I think about it, it’s probably descended directly from Prolog.
- floitsch 4y agoWe couldn't use `:` as that one is already used for too many things. We then experimented with different tokens, and `/` felt best.
- mananaysiempre 4y agoWadler’s law or not, I’m not criticising, just curious :) Thank you (and 'EricCorry in sibling comment) for taking the time to answer! [Yes, colons are nice as block introducers but don’t play nice with colons for type ascription, which is where we got Python’s asinine f(x: int, y: bool) -> str; don’t know why Rust went with that instead of ML’s uniform f(x: int, y bool): str.]
- hoosieree 4y agoAnswers from the implementors, awesome!
- ErikCorry 4y agoPart of it is that we already used colon for several things. Also types are optional in Toit, so they are a bit like comments (though they are now checked so they are less like comments now). So they look a little like // comments.