I read this article from Martin Calsyn on the new Microsoft Visualization Language called Vedea, and I must admit that I was struck by how awesome binding operators actually are. This is a feature that must make its way into C# 5! Here’s an example of a binding from his article.
textbox.Text := slider.Value;
This code looks suspiciously like Delphi. In Pascal (Delphi uses Object Pascal), := is an assignment operator. In Videa, := is a left binding assignment. What happens is that anytime the slider’s Value property is changed, the textbox.Text property updates to reflect that change.
textbox.Text :=: slider.Value;
The :=: operator is a two-way binding operator. Now, if the textbox.Text property is modified, slider.Value is changed as well.
Martin then shows just how powerful these bindings are.
myData = DataSet(“mydata.csv”);
currentYear := slider.Value + 1900;
bubbles := from row in myData
where row.Year :== currentYear
select new Circle()
{
X = row.Latitude,
Y = row.Longitude,
Radius = row.Population * scalingFactor,
Fill = BlackBodyPalette(1., 1., row.DeltaCarbon)
};
Scene[“USMap”].Add(bubbles);
This code loads data from a CSV file (similar to Jim Wooley’s LINQ to CSV) and assigns it to the myData variable. It then binds the slider.Value + 1900 to the currentYear variable; this will be used in our LINQ binding. Then a query on the data is bound to the bubbles variable which is used to show bubbles on a map. Inside of the LINQ statement, there is a boolean binding operator, :==, which assigns currentYear to the row.Year. This combines to have the powerful effect of changing the bubbles on the map to reflect the data in the CSV whenever you move the slider.
As you can see, this code is extremely powerful. It was made possible by the introduction of the DLR into the .NET framework. Kudos to the Microsoft Research team in Cambridge, UK for making such an awesome language. Now please make sure it makes its way into C# 5!