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

By on 8/15/2006 6:10 PM ()

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!

By on 8/15/2006 2:27 PM ()

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

By on 8/15/2006 6:11 PM ()

Cool, any more info on Greg Neverov's work?

By on 8/15/2006 4:09 PM ()

The feature is called "F# Active Patterns" and should be available in the next release I think. Don mentions them on his blog: [link:blogs.msdn.com] From the little I've seen it should be straightforward to use active patterns with the SyncVar/sync list datatype.

By on 8/15/2006 5:10 PM ()
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