objectionary/demu
A command line tool for DeMutabilization of EO programs
DeMu
It's a well known fact that programs with immutable objects much easy to
maintain, test and use, but the main benefit form immutable objects is that they
allow performing
more aggressive optimizations [1]
and apply more valuable analysis. DeMu is exactly the tool for removing
mutable objects like memory and cage
from EO programs. Actually, DeMu is
acronym for De-Muatabilization.
Methodology
There isn't single formal methodology or algorithm for converting mutable
objects into immutable, but we can use some separate methods to achieve this.
Using SSA form for simple cases
We actually can
apply SSA [2]
form for eo programs. This approach can immediately remove some usages of
mutable objects. Let's consider the following example:
[] > example
cage 0 > index
seq > @
index.write 1
stdout
sprintf
"%s"
index
TRUE
After applying SSA form we get something like the next:
[] > example
seq > @
stdout
sprintf
"%s"
1
TRUE
And as you can see - we removed usage of cage from the result program.
The relation between SSA form and Dataflow Languages (like EO and,
particularly, Functional Programming Languages) is quite well described in
that article [3].
Using recursion for loops
The second method is to convert loops into recursive calls.
Related articles and links
- Immutability specification and its applications
- Global Value Numbers and Redundant Computations
- SSA is Functional Programming
How to Contribute
Fork repository, make changes, send us a pull request. We will review your
changes and apply them to the master branch shortly, provided they don't
violate our quality standards. To avoid frustration, before sending us your pull
request please run full Maven build:
$ mvn clean install -PquliceYou will need Maven 3.3+ and Java 8+.