Don’t be COMMON, in Oslo MGrammar or any language for that matter.
I have yet to be convinced (some have tried) that any code libraries warranted the COMMON label. When tested by colleagues on this, it turned out that the contents of any so-called COMMON libraries could easily broken into several new libraries or had their contents attributed to existing libraries within the domain and none of them labelled as COMMON.
This really is one of my pet hates and I keep seeing it over and over again and recently came across it again whilst reading the Microsoft primer document on MGrammer. At the time of this writing the link provided here is not available, presumably due to the timing of the latest CTP drop of the Oslo tools (which now includes Quadrant) but I digress.
This is just the latest offence of the COMMON misdemeanour that I have come across.
module SongSample
{
language Common
{
// Parameterized List rule
syntax List(element)
= e:element => [e]
| es:List(element) e:element => [valuesof(es), e];
// Whitespace
syntax LF = “\u000A”;
syntax CR = “\u000D”;
syntax Space = “\u0020″;
syntax Whitespace = LF | CR | Space;
}
language Song
{
// Reference List rule in Common language
syntax Bars = bs:Common.List(Bar) => Bars[valuesof(bs)];
syntax Songs = ss:Common.List(ASong) => Songs[valuesof(ss)];
// Reference Whitespace rule in Common language
interleave Whitespace = Common.Whitespace;
}
language AnotherLanguage
{
// Reference List rule in Common language
syntax ListOfAs = Common.List(“A”);
}
}
Here we can see that in an effort to describe reusable rules across languages, a language call COMMON has been created with the idea the the syntax rule definitions might be reused, therefore becoming ‘common’ amongst the other languages that reuse them. The thing that starts me wanting to chew on my ear is the use of the word COMMON, which is a word that is descriptive of nothing! COMMON tells me nothing by looking at it. COMMON ensures that I must read the contents if I want to begin to gain an understanding. If we consider that the ‘so-called’ common language (above) contains a parameterized list rule and a set of syntax rules for whitespace, space and line termination then perhaps we can craft some description around those elements? Perhaps we might take the LF, CR, Space and Whitespace elements and put them in a language called MusicalWhitespace? Now I’m sure plenty of you can come up with a better name than that, but I guess the point is that MusicalWhitespace gives me some idea of what it might be about. I still prefer not to let my intent get lost by being common.
Let me finish by saying that I know that the author of the MGrammar in a nutshell document was using this to convey the reuse in as simple and obvious fashion possible and I am not taking a swipe at that document, on the contrary it’s a great quick start into MGrammer, it simply offered an example (albeit a non real world one) where the concept was present and could be highlighted.
No comments yet. Be the first.
Leave a reply








