jaunt-lang / jaunt

[ABANDONED] A jaunt away from Clojure
https://github.com/jaunt-lang/jaunt/issues/157
134 stars 6 forks source link

Refactoring defprotcol for syntax consistency with defn #155

Closed arrdem closed 8 years ago

arrdem commented 8 years ago

Same vein as #146, the more syntax a user has to remember the more awkward it is. I didn't realize for instance that protocol methods could be variadic, or that protocols could have docstrings attached. If they can have docstrings, why don't they have metadata same as other def forms?

Why is the parsing all done inline in one ungodly block?

Shavin' yaks....

arrdem commented 8 years ago

Before:

screenshot 2016-10-13 23 14 20

After:

screenshot 2016-10-13 23 14 01

I also took the opportunity to implement some better (but still not spec-equivalent) error message in the defprotocol implementation.

The downside here is that this is a very breaking change with regards to existing library tooling. While it codegens and runs just fine, the Jaunt test suite is now hosed because tools.namespace isn't valid anymore.

arrdem commented 8 years ago

So after thinking about this for a while - while it's nice that individual protocol methods now get leading docstring? attr-map? same as everything else it's also a huge breaking change. Either the parser should be non-positional (which technically the original parser was) or docstring? attr-map? should be trailing arguments after arglists so that this remains an additive change.

arrdem commented 8 years ago

Opting for trailing - (method-name arglists* docstring? attr-map?).