Skip to content

Conversation

@chrisrink10
Copy link
Member

@chrisrink10 chrisrink10 commented Dec 31, 2019

Support Protocols and Volatiles fully.

Protocols can be created via (defprotocol Proto) and are stored as regular maps in the Var designated by Proto. All type-making forms should support Protocols directly.

Protocol support is buoyed by a few small compiler level changes. First, the compiler now statically computes the set of arities for a function (integers and the keyword :rest for the variadic method) and attaches them to the function via the .arities attribute. Secondly, the compiler attempts to statically check Protocol interface definitions by accessing the interface located at (:interface proto) (though can always fall back to the runtime check if required).

All of the builtin collection types have had their MROs switched to place their corresponding collection interface highest in the method resolution order. This is critical for allowing the interface-matching capabilities of functools.singledispatch to work in the most natural way for users in the event that a collection type matches multiple interfaces in the MRO.

basilisp.walk was updated to use a protocol IWalkable both the validate that Protocols work and in the hopes that Protocol dispatch would be faster than the existing type which ran through a linear list of type checks to dispatch each nested invocation.

Fixes #389
Fixes #426

@chrisrink10 chrisrink10 added the wip PR is work-in-progress label Feb 25, 2020
@chrisrink10 chrisrink10 marked this pull request as draft May 26, 2020 22:49
@chrisrink10 chrisrink10 removed the wip PR is work-in-progress label May 31, 2020
@chrisrink10 chrisrink10 marked this pull request as ready for review May 31, 2020 18:54
@chrisrink10 chrisrink10 merged commit db66a17 into master May 31, 2020
@chrisrink10 chrisrink10 deleted the feature/protocols-and-volatiles branch May 31, 2020 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Volatiles Protocols

2 participants