F# compile FSharpChart: inline error
I tried to compile FSharpChart libary from http://blogs.msdn.com/b/dsyme/archive/2011/04/01/fsharpchart-wrapping-the-system-windows-forms-datavisualization-charting-charting-types.aspx, and got compile error like
Error 1 The value 'StackedArea100' was marked inline but its implementation makes use of an internal or private function which is not sufficiently ac开发者_运维百科cessible
from
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.
Can anyone enlighten me what's going on? thanks.
There is no reason why the StackedArea100
(and other similar members) should be inline
. You can fix it by replacing all occurrences of static member inline
with just static member
. If you can post a comment to the F# team's blog post, that would be great (so that they can correct this in the next release).
To add some more details:
The reason why the F# compiler doesn't like the code is that the oneXYSeq
function that is used in the implementation should be internal
and so the StackedArea100
cannot be inlined (because it would need to access an inaccessible helper function). The reason why it works in F# Interactive is that the FSharpChart.fsx
file is loaded into the current assembly, so internal
members are visible.
Andy why is there unnecessary inline
in the source code? It is because I originally experimented with using hat-types e.g. ^T
to write generic members that work with any numeric type (and hat types require inline
). Then we decided to switch to IConvertible
, so the inline
annotation is no longer needed.
精彩评论