asked
Jan 24
Hossein 81 ● 8 ● 20 Over the past few weeks, I have been grappling with Rascal to get it help me write a piece of software that parses an input file to produce LaTeX output for evaluations in the famous operational semantics of Launchbury for lazy evaluation. Thanks God that's now a done business. (I'll soon post it on my website attached with some report -- I hope!)
What I would like to drag your attention here to is the lack of support for Object-Oriented Programming (OOP). Although the Rascal development team might find this merely a pragmatic feature which may please programmers addicted to OOP, I would sincerely refuse that mindset. Here, I am sharing an example to demonstrate the added research value OOP provides to Rascal:
In my application terminology, heaps are partial functions from variable names to expressions. They are typically represented in the Set-Theoretical notation, e.g.:
G = {x1 |-> e1, x2 |-> e2}
On top of that, there is
D = (G, x3 |-> e3, x4 |-> e5, ...)
as a shorthand notation for disjoint union
D = {x1 |-> e1, x2 |-> e2, x3 |-> e3, x4 |-> e5, ...}.
For presentational purposes like that of my LaTeXification, it is important to make sure that the heaps one is working with are all normalised. For example
((G, x3 |-> e3), x4 |-> e5)
is to be normalised to
(G, x3 |-> e3, x4 |-> e5).
Given that Launchbury's semantics makes heavy use of heap union/subtraction, similar normalisations ought to take place for exactly every heap. Otherwise, funny instances like (G, ) will be produced over the course of evaluation. OOP people will, in such a case, simply put the normalisation in the constructor of the class Heap and things get sorted out in the desired scheme.
It turns out that such a funny instance does get produced in my program. I understand that there is at least one instance where normalisation should have happened and I have forgotten to place it there. My frenzy search for that instance is indeed painful, and might not necessarily succeed. For me personally, this pain is magnified because I have been using the elegant OOP constructor technique for several years in my everyday programming.
All in all, similar experiences with Rascal make me think OOP will boost Rascal development correctness drastically, and I would like to cordially recommend that to the Rascal team.