Onward

A couple of posts ago, @publicfarley had a comment with some great questions about Toccata's type system. They warrented a better response than I wanted to put in a comment, so I'm taking this post to respond.

It would be nice, however, to have a less verbose type annotation mode in the base function. In this case that would be in `add-numbers`. Something more like Clojure’s type hints.

Ok, so that's not a question. But it's an excellent point.

I considered some alternative annotation syntax and settled on this because this is only the initial implementation. It would be simple (dare I say trivial) to add a different notation to the reader. I also wanted to keep the idea that these annotations are 'just normal' code. Not some esoteric type-system thingie. In the future, I'd like to allow the body of the assertion to be any valid Toccata code and maybe implement something like this. So it's entirely likely there will be an additional annotation for assertions after we get some experience writing Toccata code.

Also, how does the dev that is creating a function like `inc` know that they are getting the benefits of `add-numbers` type enforcement?
How do they decide if they need to do it themselves or leverage that it is done later in the call chain?

For now, programmers will only know this by inspection. Most plain functions will have their contracts inferred by their use of the core library functions. There will certainly be cases where that won't be enough and in the process of finding bugs, assertions can be added to validate the programmers' mental model. Then the compiler will flag violations. I think that most type assertions will happen in deftype or defprotocol expressions. Again, we'll have to get some experience to see how things will shake out. Another goal of Toccata is to make writing tools super easy, and one to highlight all the contracts a given symbol must satisfy would be high on my list. An IDE could use this to provide that as documentation or allow it to be toggled on and off.