inline-c和language-c-inline有什么区别? [英] What are the differences between inline-c and language-c-inline?

查看:116
本文介绍了inline-c和language-c-inline有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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


  • inline-c

  • language-c-inline (它使用 b


    由于我正在寻找我自己的准引用库,我对设计选择,API差异,表现等感兴趣。



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



    你会如何区分这些软件包?根本的区别是什么?它们实际上是否相似?

    解决方案

    inline-c的reddit公告


    这与语言c-inline相比如何?







    • inline-c 中,我们有一个非常简单的核心库,可以通过附加的反向引用轻松扩展。我希望核心功能是非常可预测的,并且可以将更多的编组功能留给特定的用例。在 language-c-inline 中,编组使用硬编码规则和用户提供的模板Haskell函数。

    • 我们希望使语言尽可能简单地包含C代码。内联C与一个准标记符拼接,并且没有模板Haskell函数。内联C代码指定使用反引号捕获的Haskell变量,并且目标类型全部使用C语法指定。正如我在博客文章中所说的那样,我非常关心这种情况,要确信你在C中得到的是你所期望的。相关地,我们只检查了反引号:其余的C代码没有被解析并且保持逐字,因此我们不必担心用户正在使用的C编译器和<$ $的Haskell C解析器之间的最终不兼容c $ c> language-c-inline 使用。
    • 我们还确保基础架构和构建过程非常流畅。 addTopDecl 函数用于避免在运行时像 language-c-inline 那样填充表,而且我也使用各种技巧来确保所有内容在整个构建过程中都能顺利运行。例如,生成的C函数的名称基于函数本身内容的散列。这对于确保cabal重复构建同一文件非常重要 - 例如编译时支持分析支持 - 会生成相同的C符号,同时确保这些符号只有在C代码片段在模块中是相同的。

      [...]




    <简而言之,这两个库在精神上非常相似,但我们编码 inline-c 以更好地适应我们需要不同设计选择的需求。上面的一些优势可以很容易地移植到 language-c-inline 中,尤其是最后一点的。


    fpcomplete的公告还包含其他信息,但总而言之,是的,它们有点类似。

    I've been briefly looking into quasi-quotation libraries for Haskell. These libraries allow Haskell to integrate with other languages. For integrating with C, there appears to be two packages with similar functionality:

    As I'm looking to build a quasi-quotation library of my own, I'm interested in design choices, API differences, performance etc.

    The only difference I'm aware of is that language-c-quote supports C and Objective-C, whereas inline-c supports C.

    How would you distinguish these packages? What are the fundamental differences? Are they, in fact, similar?

    解决方案

    Some differences where (shortly) discussed in 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.

    The announcement on fpcomplete also contains additional information, but all in all, yep, their somewhat similar.

    这篇关于inline-c和language-c-inline有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆