differential-datalog icon indicating copy to clipboard operation
differential-datalog copied to clipboard

Improve support for rust "FFI"

Open Kixiron opened this issue 3 years ago • 4 comments

I've got no idea how things would work, but as-is writing rust alongside ddlog kinda sucks, especially if you write relation transformers. In an ideal scenario we'd check all these boxes:

  • Tooling support, currently things like rustfmt, clippy and cargo check just can't really function on the standalone files which makes it hard to write as well as keep to a high code quality
  • Multi-file integrations, the current meta of only being able to have one rust file per ddlog module is very limiting, ideally we'd be able to have arbitrary structures of code alongside it

Again I don't really know how we'd go about this, maybe we'd require external code to be a library crate supplied by the user that we connect to with ddlog or something which could be really advantageous for a number of reasons, such as being able to link multiple rust crates into a single ddlog module with this hypothetical syntax

#[path = "your_custom_crate_name::ddlog_ffi::foo_bar_baz"]
extern function foo_bar_baz(value: 'T)

Kixiron avatar May 15 '21 19:05 Kixiron

A straightforward generalization of the current design would be to allow a directory containing a Rust crate per DDlog module.

ryzhyk avatar May 17 '21 02:05 ryzhyk

That'd definitely be nice, but it still suffers from the problems of tooling not working properly

Kixiron avatar May 17 '21 19:05 Kixiron

If the Rust directory is a self-contained crate, there's no reason Rust tooling wouldn't work on it. But if it depends on Rust code generated from DDlog, one would have to run the ddlog compiler before running Rust tools.

ryzhyk avatar May 18 '21 00:05 ryzhyk

Oh, I thought you were meaning to just extend it to a module and not a crate.

One would have to run the ddlog compiler before running Rust tools

Yah, unfortunately I don't really think there's a perfect solution

Kixiron avatar May 18 '21 01:05 Kixiron