1

我尝试从http://blogs.msdn.com/b/dsyme/archive/2011/04/01/fsharpchart-wrapping-the-system-windows-forms-datavisualization-charting-charting-types.aspx编译 FSharpChart 库,并得到编译错误,如

Error   1   The value 'StackedArea100' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible   

type FSharpChart =
    /// Displays multiple seriesÿof data as stacked areas. The cumulative proportion
    /// of each stacked element is always 100% of the Y
    /// axis.
    static member StackedArea100<'TY when 'TY :> IConvertible>(data: seq<'TY>) = 
        GenericChart<_>.Create<StackedArea100Chart>(oneY data)
    /// Displays multiple seriesÿof data as stacked areas. The cumulative proportion
    /// of each stacked element is always 100% of the Y
    /// axis.
    static member inline StackedArea100<'TX, 'TY when 'TX :> IConvertible and 'TY :> IConvertible>(data:seq<'TX * ('TY)>) = 
        GenericChart<_>.Create<StackedArea100Chart>(oneXYSeq data)
    /// Displays multiple seriesÿof data as stacked areas. The cumulative proportion
    /// of each stacked element is always 100% of the Y
    /// axis.

谁能启发我这是怎么回事?谢谢。

4

1 回答 1

3

(和其他类似成员)没有理由StackedArea100应该是inline. 您可以通过将所有出现的 替换为static member inlinejust来修复它static member。如果您可以在 F# 团队的博客文章中发表评论,那就太好了(以便他们可以在下一个版本中更正此问题)。

添加更多细节:

F# 编译器不喜欢该代码的原因是oneXYSeq实现中使用的函数应该是internal,因此StackedArea100不能内联(因为它需要访问不可访问的辅助函数)。它在 F# Interactive 中工作的原因是FSharpChart.fsx文件被加载到当前程序集中,因此internal成员是可见的。

inlineAndy 为什么在源代码中有不必要的?这是因为我最初尝试使用帽子类型,例如^T编写适用于任何数字类型的通用成员(并且帽子类型需要inline)。然后我们决定切换到IConvertible,因此inline不再需要注释。

于 2011-05-26T19:40:54.280 回答