[...] This feels like a bug, but perhaps I'm missing something with the syntax. Can anyone point out why this code fails?

Ah ha! Issue solved (sort of, see below). Aside from the other error (that "item" is never defined), the problem is with my indenting. When using #light syntax, the "done" must be indented under the "do", rather than under the "while", as in the following fully corrected version:

1
2
3
4
5
6
7
8
9
10
module Seq =
    let takeUntil' (p:'a->bool) (s:seq<'a>) =
        seq { let e = s.GetEnumerator() in
              let bMore = ref (e.MoveNext()) in
              while !bMore do
                  let item = e.Current in
                  yield item
                  do bMore := not (p item) && e.MoveNext();
                  done
            }

But wait! This works for "#light" mode, but it does not compile for non-light mode! The "yield" statement looks like it wants to have a semi-colon after it, but it works neither with nor without one: both result in a syntax error.

By on 6/9/2008 4:18 PM ()

Hi,

Currently, workflows can't be used with non-light syntax. This is a known limitation (cf. [link:cs.hubfs.net]).

Laurent.

By on 6/10/2008 2:38 AM ()

Just remove the "done". It's not needed in the #light syntax (although, it shouldn't do a parse error).

Laurent.

By on 6/9/2008 9:06 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