【问题标题】:Resolve library conflict in SML/NJ Compilation Manager解决 SML/NJ 编译管理器中的库冲突
【发布时间】:2016-04-15 20:36:00
【问题描述】:

我正在使用 SML/NJ 110.79,其中包括对 Successor ML 项目定义的新结构的支持。其中包括Fn 结构。

碰巧的是,我已经在my personal project with utilities 之一中有一个同名结构,它在 110.79 之前运行良好。

对于 110.79,对于这个 .cm 文件:

group is
  $/basis.cm
  $SMACKAGE/sml-extras/v0.1.0/sources.sml.cm

我收到以下错误:

sources.cm:3.3-3.45 错误:结构 Fn 导入自 $SMLNJ-BASIS/(basis.cm):basis-common.cm@155252(fn.sml) 也来自 $SMACKAGE/sml-extras/v0.1.0/(sources.sml.cm):src/fn.sml

有谁知道如何通过编译管理器解决这个冲突。理想情况下,我的 Fn 结构将能够通过 open-ing 来“扩展”标准 Fn,但使用 sml-extras 库的项目将看不到标准 Fn 结构,只有我的扩展版本。

这可能吗?我需要在我的 sml-extras.cm 项目中包装/重新导出整个 basic.cm 库吗?

【问题讨论】:

  • 有趣的问题。最简单的解决方法是更改​​您的Fn 版本的名称(例如更改为Fnct)。编译管理器确实具有条件编译功能。此外——新版本的发行说明就如何处理新功能破坏旧代码的情况提供了一些建议。
  • @JohnColeman 重命名结构是我的最后一个选择 :) 暂时,我已更改为使用 $/basis-2004.cm,而不是新的,只是为了编译代码。

标签: sml smlnj cm


【解决方案1】:

我设法通过使用CM manual §2.9 中我认为称为管理 的库来解决这个问题。

这意味着创建一个辅助 .cm 文件,该文件包装基础库并仅重新导出我们感兴趣的符号。

sources.cm

这是主项目文件。

library
  structure Main
is
  (* Let's say this library redefines the Fn and Ref structures    *)
  (* and the REF signature.                                        *)
  $SMACKAGE/sml-extras/v0.1.0/sources.sml.cm

  (* This excludes out Fn, Ref and REF from the Basis library, but *)
  (* imports anything else.                                        *)
  amended-basis.cm

  main.sml

amended-basis.cm

此文件导入$/basis.cm,然后重新导出除FnRefREF 之外的所有文件。

group
  library($/basis.cm) - (
    structure Fn
    structure Ref
    signature REF
  )
is
  $/basis.cm

main.sml

structure Main =
  struct
    open Fn (* sml-extras's Fn *)
  end

该解决方案基于 CM 手册第 4 节中描述的 set calculus 以及附录 A 中的 EBNF 语法。

另一种解决方案是更改 sml-extras 以重新导出整个 $/basis.cm,同时隐藏冲突的符号。但是,出于模块化的考虑,我决定采用上面详述的解决方案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-07
    • 1970-01-01
    • 1970-01-01
    • 2010-10-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多