mozilla / mentat

UNMAINTAINED A persistent, relational store inspired by Datomic and DataScript.
https://mozilla.github.io/mentat/
Apache License 2.0
1.65k stars 115 forks source link

Use macros to generate specialized type FFI functions #703

Open fluffyemily opened 6 years ago

fluffyemily commented 6 years ago

Currenty in our FFI we have a number of functions that essentially to do the same thing but accepting different types. This is to make the API profile easier for consuming clients. However this makes for a lot of repetition of code and causes a lot of work to occur if Mentat's API changes in these areas.

This issue tracks creating Macros for generating type specific FFI functions to avoid duplication of work. These macros should cover the following FFI functions.

victorporof commented 6 years ago

Is this repetition that much of an issue today? My experience with macros is that their use tends towards eventually obfuscating what's going on, or at least making things a bit harder to read in the long run, especially when there's multiple moving parts/parameters. I have a feeling that regular statically typed code is in most cases preferable (but have no data to back this up).

I share that they make a lot of sense when there's extreme or simple repetition, but I didn't get that feeling when poking into the ffi code.