Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
tomoyuki-nakabayashi Cleaned up some code
* Changed all c_void to use custom Impl opaque type.
* Documented vtable.populate
* Added Writer and ReadWriter + implementations
Latest commit b643ca9 Apr 5, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Cleaned up some code Apr 5, 2019
.gitignore Initial commit Dec 12, 2018
LICENSE Initial commit Dec 12, 2018
README.md Update README.md Dec 13, 2018

README.md

The current "interface field" pattern in Zig has problems:

  • It's too easy to shoot yourself by copying the interface out of its implementation: #591.
  • It is unfriendly to the optimizer.
  • People don't like this pattern and find it hard to understand.

This repo is an alternative way of having userland interfaces and is designed around the idea that the current interfaces are mostly used to get the helper functions they provide, and not the dynamic dispatch. We, therefore, separate the two.

  • A helper function is just a generic function that expects that the argument passed have certain functions that it can call (could have enhanched validation with #1669).
  • When dynamic dispatch is needed, one can wrap their datastructure in a struct {vtable: *c_void, impl: *c_void} data structure and provide the same interface that the helper functions expect.

What do we gain from this?

You can’t perform that action at this time.