fdopen / ppx_cstubs

preprocessor for easier stub generation with ocaml-ctypes
https://fdopen.github.io/ppx_cstubs/
Other
55 stars 5 forks source link

License for code examples in documentation #11

Open sidkshatriya opened 1 year ago

sidkshatriya commented 1 year ago

There are some useful code examples in the documentation, especially regarding static callbacks, for instance.

See https://github.com/fdopen/ppx_cstubs/blob/638b019ab5eb0d8a187710d00414a1d2536e249c/docs/static_callbacks.md

The general algorithm is straightforward: We store the data associated with each closure in a hash table (with function store_closure). The hash table is keyed with an automatically incrementing integer. This integer is converted to a raw pointer and given to the C-code when we register the callback. This raw pointer (i.e. integer) is given back to us by the C-code when the OCaml callback is invoked and we can look up the same hash table with it to get the data for the closure (with function get_closure).

This is great and there are probably not many alternative approaches to implement this algorithm in OCaml in a simpler/nicer way than you have done.

It would greatly appreciated if you can clarify the license the code samples appearing in the documentation fall under, if people want to reuse this

Ideally, the code samples would be under a liberal license/CC0. Interestingly the Ocaml project has recently done this -- see https://github.com/ocaml/ocaml/pull/12097

If sample code is under LGPL too then again one would need to understand if there are any license virality implications since now you would now be using this directly in your code.

To not worry about licensing one could argue that that you could just re-implement this algorithm yourself but it essentially be the sample implementation because there not that many ways of writing the same algorithm in OCaml !

To sidestep all this, I thought it might be better to raise a GitHub issue and request a clarification. This will be useful for everyone who wants to use static callbacks with ppx_cstubs.

sidkshatriya commented 1 year ago

TL;DR

Thanks so much for this library, it is very useful.

fdopen commented 1 year ago

The code examples in the documentation are public domain (CC0). When I eventually find the time, I'll make that explicitly clear in a commit.

sidkshatriya commented 1 year ago

Gentle ping :-)

sidkshatriya commented 2 months ago

@fdopen Gentle ping :-) -- please see https://github.com/fdopen/ppx_cstubs/issues/11#issuecomment-1497081459