Tuesday, 15 July 2014

visual studio 2013 - Object expression, interface implementation, verbose syntax -


I often use verbose syntax to create a line expression, which usually has several rows. Normally I do this so that I can send the whole expression # code> Alt + ' with the F code. For example, I can do this:

  long period list = REC assistant result = function [] -> Results | _ :: T - & gt; For the example code, assume that these namespaces have been opened:  
  open system open (helper + 1l) t helper 0L list assistant (results + 1l) t  

System I want to translate this object expression into one line:

  empty empty number = {new INMATOR < Int & gt; Member t.Current = raise (InvalidOperationException ()) with member t.MoveNext () = wrong member t.Reset () = () member t.Current = raise (InvalidOperationException ()) Interface with the interface IEnumerator member t.Dispose With IDisposable () = ()}  

I have found that I can do this only by using verbose syntax. Generally, Verbose-Syntax code also compiles under light syntax, but here, it is not. I also tried to create an enrolled class with the same implementation, and that almost identical code compiled under both light and verbose syntax:

  open system open system Collection Open System Selection. Genre # Light "Close" Type A () = Class Interface IEnumerator & lt; Int & gt; Member t.Current = raise (invalid operation exception) member interface IEnumerator member with t.MoveNext () = wrong member t.Reset () = () member t.Current = raise (InvalidOperationException ()) IDC with member interface Forget (=) end at end B = {new IEnumerator & lt; Int & gt; Member t.Current = raise (invalid operation exception) member interface IEnumerator member with t.MoveNext () = wrong member t.Reset () = () member t.Current = raise (InvalidOperationException ()) IDC with member interface Dispute () = (end of end) # Light on "Type" (C =) Interface IEnumerator & lt; Int & gt; Member t.Current = raise (invalid operation exception) member interface IEnumerator member with t.MoveNext () = wrong member t.Reset () = () member t.Current = raise (InvalidOperationException ()) IDC with member interface Forget (=) end (end) d = {new IEnumerator & lt; Int & gt; Member t.Current = raise (invalid operation exception) member interface IEnumerator member with t.MoveNext () = wrong member t.Reset () = () member t.Current = raise (InvalidOperationException ()) IDC with member interface Definitions of both classes succeed, but the last line fails with "~ vsB756.fsx (29,150)": Error FS0010: Unexpected keyword expression in 'member'. Incomplete structured construction on or before this point or other token. " 

The problem appears to be in the series of member definitions. Second and third members IEnumerator part of the definition of Visual Studio FS 10010 error as the reasons for the error > Highlights the keyword. (In other words, the highlighted member are keywords that are IEnumerator.Reset () and IEnumerator.Current .)

Visual Studio open brace (mismatch '{'}, and end keywords Reporting errors on "two" before the code (incomplete value or function definition)> IDisposable implementation, but I suspect that it caused three members in the IEnumerator implementation Failed to recognize it, due to which it tries to parse additional members as part of the definition of first member.

Have I ignored some of the syntax? Is this a compiler in one Bug Land?


No comments:

Post a Comment