hubFS: THE place for F#

. . . are you on The Hub?
Welcome to hubFS: THE place for F# Sign in | Join | Help
in Search

source for libraries? thread info?

Last post 08-15-2006, 18:11 by dsyme. 5 replies.
Sort Posts: Previous Next
  •  08-15-2006, 12:43 509

    source for libraries? thread info?

    Is the source code for F#'s libraries available?

    I was trying to compare the code of List and LazyList so I could figure out the best way of adding something like a SyncVarList (I'll think of a better name later).  This would basically be a producer/consumer queue.  I wanted a list which can be 'hooked up' to a messaging system.  In other words, the tail is a SyncVar (from Scala), if the SyncVar is not bound to anything, an attempt to access its value will put the 'consumer' sleep, when something is bound to it, the consumer will be woken up.

    This will allow one to process continous data feeds, such as stock quotes, to be process as easily as one processes a normal list.


    Also, I didn't see any information on how to use threads with F#.  Is it possible to have very light weight threads (I believe light weight threads are done using continuations...way out of my league).  Thanks.
  •  08-15-2006, 14:27 514 in reply to 509

    Re: source for libraries? thread info?

    Threading in F# is mostly via System.Threading, and not via any language-specific features. Implementing SyncVar with System.Threading should be straightforward though. SyncVars will need an object to use as a monitor; writing to a SyncVar should acquire the monitor, set the value, and pulse; reading a SyncVar should acquire the monitor, yield until the value is set, and pulse on exit (in case there are multiple readers.) I'm not familiar with Scala SyncVars or what semantics you want for the list (for example, can the producer produce nothing, i.e. nil is also lazy, etc.)

    I believe you can use Greg Neverov's new patterns feature to make unpacking sync lists as easy as matching on lists! Should be cool!

  •  08-15-2006, 16:09 517 in reply to 514

    Re: source for libraries? thread info?

    Cool, any more info on Greg Neverov's work?
  •  08-15-2006, 17:10 519 in reply to 517

    Re: source for libraries? thread info?

    The feature is called "F# Active Patterns" and should be available in the next release I think. Don mentions them on his blog: http://blogs.msdn.com/dsyme/archive/2006/08/13/696931.aspx From the little I've seen it should be straightforward to use active patterns with the SyncVar/sync list datatype.
  •  08-15-2006, 18:10 520 in reply to 509

    Re: source for libraries? thread info?

    Prompted by this discussion I've added a blog post on active patterns to my MSR Cambridge blog.

    Certainly in the case above it looks like you expect the patterns to block on SyncVar constructs (or their equivalents) - that is feasible as long as a second or third read from a SyncVar will continue to return the same results.  However, any pattern matching techniques involving side effects (e.g. blocking!) must be used with extreme caution.  (One reason why I go to pains to label active patterns as experimental is that we are yet to explore all the use-case scenarios sufficiently to give detailed guidlelines for their use.)

    Don

     

  •  08-15-2006, 18:11 521 in reply to 514

    Re: source for libraries? thread info?

    BTW to answer the original question of this thread, the source for the F# libraries is available in the lib/fslib and lib/mllib directories in the distribution.

    don

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems