Saturday, December 17, 2011

Event chaining question

http://cs.hubfs.net/topic/Some/2/58245

Hi divisortheory.
Thanks for your mouse posts, 2 years on, yet relavent.
Merry Winter Solstice 2011! Happy New Year 2012!!

I've been postpoining F# interactive  manipulation until I read
Jon Harrop's F# .NET Journal article on Quickhull which got my attention -
"A key aspect of the GUI is the ability to drag and drop points in the point set and watch the convex hull as it is recomputed in real time. The following drag value is the current state of the outstanding drag operation, if any, represented by the index of the point being dragged:
<code lang="fsharp">
    > let drag : int option ref = ref None;;
    val drag : int option ref = {contents = null;}
</code>
This design follows the mantra "make illegal states unrepresentable". Alternative designs in languages where this cannot be so easily expressed tend to use one boolean variable to indicate whether or not a drag is in progress and another integer variable to convey the index when meaningful. Using data structures such as the option type in F# precludes the possibility of non-sensical values being created and encountered at run-time, reducing the scope for errors and the number of run-time tests."

I'm trying to comprehend the lesson.
PLH OOE Art Scott twitter @semasiographic

Event chaining question