2009-05-28 19 views
5

एफ # के नवीनतम संस्करण में कुछ कोड माइग्रेट करते समय, वीएस -2010 बी 1 में शामिल है, मुझे एक समस्या का सामना करना पड़ा है और मैं जानना चाहता हूं कि कोई कामकाज उपलब्ध है या नहीं - एफ # कंपाइलर का व्यवहार परिदृश्य का समर्थन न करने के लिए क्यों संशोधित किया गया था।एफ #: करीबी अधिभार/tupled अधिभार मुद्दा

error FS0191: One or more of the overloads of this method has curried arguments. Consider redesigning these members to take arguments in tupled form

कृपया ध्यान रखें कि यह एफ # 1.9.6.2 (सितम्बर CTP)

उत्तर

7

के लिए कारण पर दोषरहित काम करता था:


type Foo(a) = 
    [<OverloadID("CurriedAbc")>] 
    member public x.Abc (p:(oneType * anotherType) seq) otherParm = method impl... 

    //this overload exists for better compatibility with other languages 
    [<OverloadID("TupledAbc")>] 
    member public x.Abc (p:Dictionary<oneType, anotherType>, otherParm) = 
     x.Abc(p |> Seq.map(fun kvp -> (kvp.Key, kvp.Value))) otherParm 

इस कोड को निम्नलिखित संकलन-टाइम त्रुटि पैदा करता है

Optimizations for Curried Methods

A curried member looks like this:

type C() =

static member Sum a b = a + b  

In previous implementations of F# curried members were compiled less efficiently than non-curried members. This has now been changed. However, there are now some small restrictions on the definition of curried members:

  • curried members may not be overloaded
  • some definitions of curried members may need to be adjusted to add the correct number of parameters to the definition

के बाद से अपने ओवरलोडिंग पर हल किया जा सकता: परिवर्तन में detailed release notes है शीर्षक मुद्दा ओर इशारा करते हुए के लिए

[<OverloadID("CurriedAbc")>] 
    member public x.Abc (p:(oneType * anotherType) seq) 
     = fun otherParm -> method impl... 
+0

धन्यवाद, मैं एक और समस्या है जो मुझे ठीक करने के लिए मिल गया और उसके बाद के लिए एक सवाल लिख रहा था: पहले पैरामीटर पर ly, आप के लिए curried संस्करण बदलकर दौर काम करने के लिए सक्षम होना चाहिए यह एक आया और मैं सिर्फ शीर्षक के बारे में भूल गया :( पीएस: मैं अभी यह देखने के लिए अपने समाधान का परीक्षण कर रहा हूं कि यह काम करता है या नहीं: डी – em70

संबंधित मुद्दे