This is absolutely a bug and it will be fixed in the next release.

By on 4/21/2009 8:45 PM ()

Ah! You're right, intellisense is binding to the XName, I never even considered that.

Thanks for all the responses and Michael for the tip using the parens.

m

By on 4/22/2009 5:47 AM ()

I'll just add a bit to Michael's reply.

>> When you make a method call with no space before the parens, the method call binds
>> higher than the dot accessor.

That's how the compiler binds, but problem is that intellisense is behaving differently from the compiler.

When you enter the dot, intellisense is binding the dot to (xname elements) rather than elementDocuments.Element(...).

I can't tell you the history behind this. It may even be by design, and overall the best choice.

You can get it to bind the other way by using brackets...

let elements = (elementDocument.Element(xname "elements")).

I do this all the time - add brackets to get intellisense working, and then remove them. So much, that I've stopped noticing it, and don't even think about a "bug".

Maybe it is a bug - thanks for bringing it up. Let's hope the F# elves at Microsoft have something to say.

@mobrien: ... or I'm not thinking functionally...

It does take quite a while to get used to F# function application being different from C#, and then mixing and matching the two (when calling .Net). I do a lot of shifting of brackets.

@mobrien: ... Maybe something to do with type inference?

Good guess, but I don't think so

By on 4/21/2009 8:30 PM ()

I think that's an annoying bug in Intellisense. When you make a method call with no space before the parens, the method call binds higher than the dot accessor.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 

> File.ReadAllLines("C:\\boot.ini").Substring(0, 10);;

  File.ReadAllLines("C:\\boot.ini").Substring(0, 10);;
  ----------------------------------^^^^^^^^^^

stdin(94,35): error FS0039: The field, constructor or member 'Substring' is not defined.


> File.ReadAllLines ("C:\\boot.ini").Substring(0, 10);;

  File.ReadAllLines ("C:\\boot.ini").Substring(0, 10);;
  ------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

stdin(95,19): error FS0191: Successive arguments should be separated by spaces or tupled, and arguments involving function or method applications should be parenthesized.

Thsi is section 15.2 of the F# spec. It's one of those quirks to make .NET interop nicer.

By on 4/20/2009 9:18 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper