inline-c 和 language-c-inline 有什么区别?

What are the differences between inline-c and language-c-inline?

我一直在简要研究 Haskell 的准引用库。这些库允许 Haskell 与其他语言集成。为了与 C 集成,似乎有两个具有相似功能的包:

因为我正在寻找自己的准报价库,所以我对设计选择、API 差异、性能等很感兴趣。

我知道的唯一区别是 language-c-quote 支持 C 和 Objective-C,而 inline-c 支持 C。

您如何区分这些包裹?根本区别是什么?他们真的很相似吗?

inline-c's reddit announcement 中(不久)讨论的一些差异:

How does this compare to language-c-inline?

  • In inline-c we have a very simple core library which is easily extensible with additional anti quoters. I wanted the core functionality to be very predictable, and leave fancier marshalling up to specific use cases. In language-c-inline the marshalling works with a mix of hard-coded rules and user-supplied Template Haskell functions.
  • We wanted to make the language to include the C code as simple as possible. The inline C is spliced with a quasi quoter and no Template Haskell functions. The inline C code specifies the Haskell variables to capture using anti-quoters, and the target types are all specified using C syntax. As I say in the blog post I cared quite a bit that this is the case, to have confidence that what you're getting in C is what you expect. Relatedly, only the anti-quoters are examined: the rest of the C code is not parsed and left verbatim, so we don't have to worry about eventual incompatibilities between the C compiler the user is using and the Haskell C parser that language-c-inline uses.
  • We're also making sure that the infrastructure and build process is smooth. The addTopDecl function is used to avoid having to populate tables at runtime like language-c-inline does, and I also employ various tricks to make sure that everything will work smoothly across builds. For example, the names of the generated C functions is based on the hash of the contents of the function itself. This is quite important to guarantee that repeated builds of the same file by cabal -- for example when compiling with profiling support -- result in the same C symbols being generated, while making sure that the the symbols are the same only if the C snippets in the module are the same.

    […]

In short, the two libraries are very similar in spirit, but we coded inline-c to be better suited to our needs taking different design choices. Some of the advantages above could be easily ported to language-c-inline, especially the ones in the last point.

announcement on fpcomplete 还包含其他信息,但总而言之,是的,它们有些相似。