<?xml version="1.0" encoding="utf-8"?><!-- generator="wordpress/1.5.1.3" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Oddities in F#/C# interaction</title>
	<link>http://www.sturmnet.org/blog/archives/2008/05/16/oddities-in-fc-interaction/</link>
	<description>General musings and programming stuff</description>
	<pubDate>Sun, 12 Oct 2008 06:26:47 +0000</pubDate>
	<generator>http://wordpress.org/?v=1.5.1.3</generator>

	<item>
		<title>by: Oliver Sturm</title>
		<link>http://www.sturmnet.org/blog/archives/2008/05/16/oddities-in-fc-interaction/#comment-163968</link>
		<pubDate>Sat, 17 May 2008 14:19:27 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2008/05/16/oddities-in-fc-interaction/#comment-163968</guid>
					<description>Thanks, that might be a good idea - can't try right now - since I've already found another workaround that involved putting int(v) to the function instead of v on its own. For certain other reasons (I want to do CodeRush templates for this, and there are certain type translation algorithm not in place yet for F#) I couldn't use that workaround. Having the type constraint in the place you're suggesting will probably solve the problem for me.

I hope you guys are taking these things up as bugs though - so far I haven't heard anybody saying &amp;#34;it works exactly as expected and here's why&amp;#34;!

Thanks for all your help, Brian - sounds like you've really dug in by now - in the F# session at the MVP summit you came over just a little bit nervous and I understood it was due to a certain lack of experience at that point ;-)</description>
		<content:encoded><![CDATA[	<p>Thanks, that might be a good idea - can&#8217;t try right now - since I&#8217;ve already found another workaround that involved putting int(v) to the function instead of v on its own. For certain other reasons (I want to do CodeRush templates for this, and there are certain type translation algorithm not in place yet for F#) I couldn&#8217;t use that workaround. Having the type constraint in the place you&#8217;re suggesting will probably solve the problem for me.</p>
	<p>I hope you guys are taking these things up as bugs though - so far I haven&#8217;t heard anybody saying &quot;it works exactly as expected and here&#8217;s why&quot;!</p>
	<p>Thanks for all your help, Brian - sounds like you&#8217;ve really dug in by now - in the F# session at the MVP summit you came over just a little bit nervous and I understood it was due to a certain lack of experience at that point <img src='http://www.sturmnet.org/blog/wp-images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: BrianMcNamara</title>
		<link>http://www.sturmnet.org/blog/archives/2008/05/16/oddities-in-fc-interaction/#comment-163930</link>
		<pubDate>Sat, 17 May 2008 13:21:48 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2008/05/16/oddities-in-fc-interaction/#comment-163930</guid>
					<description>Sorry, I haven't been able to log into the hub lately to reply.
In your overload example, you have a setter with &amp;#34;set(v)&amp;#34;, but &amp;#34;v&amp;#34; is unconstrained.  If you constrain it to be &amp;#34;int&amp;#34; (rather than 'a), then it will work: &amp;#34;set(v:int)&amp;#34;.  That should explain why it's happening, too.
This is a case where hovering over the variable name with the mouse in Visual Studio to see the type helps a lot.</description>
		<content:encoded><![CDATA[	<p>Sorry, I haven&#8217;t been able to log into the hub lately to reply.<br />
In your overload example, you have a setter with &quot;set(v)&quot;, but &quot;v&quot; is unconstrained.  If you constrain it to be &quot;int&quot; (rather than &#8216;a), then it will work: &quot;set(v:int)&quot;.  That should explain why it&#8217;s happening, too.<br />
This is a case where hovering over the variable name with the mouse in Visual Studio to see the type helps a lot.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Oliver Sturm</title>
		<link>http://www.sturmnet.org/blog/archives/2008/05/16/oddities-in-fc-interaction/#comment-163900</link>
		<pubDate>Sat, 17 May 2008 12:07:51 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2008/05/16/oddities-in-fc-interaction/#comment-163900</guid>
					<description>Brian, if you're reading these comments - do you have any thoughts on the original &amp;#34;resolve overload conflict problem&amp;#34;? I'm not getting any feedback on hubFS, should I report this somewhere else? What's the right place to go for that?</description>
		<content:encoded><![CDATA[	<p>Brian, if you&#8217;re reading these comments - do you have any thoughts on the original &quot;resolve overload conflict problem&quot;? I&#8217;m not getting any feedback on hubFS, should I report this somewhere else? What&#8217;s the right place to go for that?
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Oliver Sturm</title>
		<link>http://www.sturmnet.org/blog/archives/2008/05/16/oddities-in-fc-interaction/#comment-163898</link>
		<pubDate>Sat, 17 May 2008 12:02:38 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2008/05/16/oddities-in-fc-interaction/#comment-163898</guid>
					<description>Okay, I think I solved this latest problem. I changed the helper function to this signature:

    member public x.SetPropertyValueFS(propertyName, (oldVal: 'a byref), (newVal: 'a)) = 

That makes it compile correctly - haven't tested functionality yet. And the &amp;#34;byref&amp;#34; keyword is another thing I haven't found documented anywhere... I just guessed from the error message that there could be such a keyword.</description>
		<content:encoded><![CDATA[	<p>Okay, I think I solved this latest problem. I changed the helper function to this signature:</p>
	<p>    member public x.SetPropertyValueFS(propertyName, (oldVal: &#8216;a byref), (newVal: &#8216;a)) = </p>
	<p>That makes it compile correctly - haven&#8217;t tested functionality yet. And the &quot;byref&quot; keyword is another thing I haven&#8217;t found documented anywhere&#8230; I just guessed from the error message that there could be such a keyword.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Oliver Sturm</title>
		<link>http://www.sturmnet.org/blog/archives/2008/05/16/oddities-in-fc-interaction/#comment-163735</link>
		<pubDate>Sat, 17 May 2008 10:32:17 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2008/05/16/oddities-in-fc-interaction/#comment-163735</guid>
					<description>Hi Brian,

Thanks for the info with the &amp;#38;var style parameter passing - haven't seen than anywhere before! I tried it in a simple test and it works, but I'm still having problems in my precise use case - with a member like this:

  member public x.Age
    with get() = x.age
    and set(v) = x.SetPropertyValueFS(&amp;#34;Age&amp;#34;, &amp;#38;x.age, v) &amp;#166;&amp;#62; ignore

I'm getting a weird error: &amp;#34;Error 3 Type constraint mismatch. The type 'b byref is not compatibile with type  'a ref. The type ''b byref' is not compatible with the type ''a ref'.&amp;#34;

For the second problem though - yes, I can see where that problem comes from with curried parameter lists (if you accept that capturing the protected method isn't allowed). Your suggestion solves my problem, so thanks for that! I still don't understand what makes that particular call so problematic, since the same thing works in simple tests I did...</description>
		<content:encoded><![CDATA[	<p>Hi Brian,</p>
	<p>Thanks for the info with the &amp;var style parameter passing - haven&#8217;t seen than anywhere before! I tried it in a simple test and it works, but I&#8217;m still having problems in my precise use case - with a member like this:</p>
	<p>  member public x.Age<br />
    with get() = x.age<br />
    and set(v) = x.SetPropertyValueFS(&quot;Age&quot;, &amp;x.age, v) |&gt; ignore</p>
	<p>I&#8217;m getting a weird error: &quot;Error 3 Type constraint mismatch. The type &#8216;b byref is not compatibile with type  &#8216;a ref. The type &#8216;&#8217;b byref&#8217; is not compatible with the type &#8216;&#8217;a ref&#8217;.&quot;</p>
	<p>For the second problem though - yes, I can see where that problem comes from with curried parameter lists (if you accept that capturing the protected method isn&#8217;t allowed). Your suggestion solves my problem, so thanks for that! I still don&#8217;t understand what makes that particular call so problematic, since the same thing works in simple tests I did&#8230;
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Brian McNamara</title>
		<link>http://www.sturmnet.org/blog/archives/2008/05/16/oddities-in-fc-interaction/#comment-163655</link>
		<pubDate>Sat, 17 May 2008 03:20:39 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2008/05/16/oddities-in-fc-interaction/#comment-163655</guid>
					<description>I think if you don't curry the arguments
    member public x.SetPropertyValueFS(propertyName, oldVal, newVal) =
then it will work.  When they're curried, this effectively makes the .NET method take one argument and return a lambda or the rest of the arguments, and that lambda is capturing a call to a protected method.  For reasons that are still unclear to me, that's not allowed.   But you can work around it simply by making the method take parameters &amp;#34;(like, this)&amp;#34; rather than &amp;#34;like this&amp;#34;.</description>
		<content:encoded><![CDATA[	<p>I think if you don&#8217;t curry the arguments<br />
    member public x.SetPropertyValueFS(propertyName, oldVal, newVal) =<br />
then it will work.  When they&#8217;re curried, this effectively makes the .NET method take one argument and return a lambda or the rest of the arguments, and that lambda is capturing a call to a protected method.  For reasons that are still unclear to me, that&#8217;s not allowed.   But you can work around it simply by making the method take parameters &quot;(like, this)&quot; rather than &quot;like this&quot;.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Brian McNamara</title>
		<link>http://www.sturmnet.org/blog/archives/2008/05/16/oddities-in-fc-interaction/#comment-163644</link>
		<pubDate>Sat, 17 May 2008 02:45:18 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2008/05/16/oddities-in-fc-interaction/#comment-163644</guid>
					<description>FYI, you can pass 'by ref' using the prefix '&amp;#38;' operator on a mutable:

#light

open System.Collections.Generic 

let mutable x = 1
let d = new Dictionary&amp;#60;string,int&amp;#62;()
d.Add(&amp;#34;foo&amp;#34;, 42)
if d.TryGetValue(&amp;#34;foo&amp;#34;, &amp;#38;x) then
    printfn &amp;#34;x = %d&amp;#34; x</description>
		<content:encoded><![CDATA[	<p>FYI, you can pass &#8216;by ref&#8217; using the prefix &#8216;&amp;&#8217; operator on a mutable:</p>
	<p>#light</p>
	<p>open System.Collections.Generic </p>
	<p>let mutable x = 1<br />
let d = new Dictionary&lt;string,int&gt;()<br />
d.Add(&quot;foo&quot;, 42)<br />
if d.TryGetValue(&quot;foo&quot;, &amp;x) then<br />
    printfn &quot;x = %d&quot; x
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
