Menu

Co-op III Scala

Steven te Brinke

This page is currently work in progress

Installing Scala

  • In the Eclipse containing the Co-op project add the Scala update site and install Scala from there.
  • To be able use Scala in the generated Co-op IDE open the run configuration for the Co-op IDE, go to the configuration tab and under Configuration file select "Use an existing config.ini file as an template".
  • Make sure to enable Scala in the Co-op IDE. Go to Scala -> Run setup diagnostics and make sure "Enable JDT weaving" is selected
  • todo: try/explain, Add scala nature to project

CoopObject

Functions that are in the coop objects (including getters and setters) that are not called in the program are not added as functions to CoopObject, this results in the functions not being able to overwrite them because they are not present in CoopObject. This leads to invalid code being compiled when using the same approach as Java. Possible solutions:

  • See what getters and setters are used when generating the code for them in the child classes and specify the override keywords when these functions are used.
  • Add all getters and setters to CoopObject, not just the getters and setters that are used.

Even tough this is not possible yet partial compilation would become more difficult to do and would need to be done more often when using solution 1.

When using solution 2 CoopObjects gets more methods that are never used.

..... explain decision .....

Field access modifiers

TODO: Look into access modifiers of fields, currently made all public

Annotations

TODO: Test cases pass but might need more testing

EDIT: Not working anymore, i forgot to do the initial annotations
the «declareAllAnnotations(c)» in the annotation Object
Some mobilizations refer to a method which I cannot access since the code is executed in the object but i think this needs to be moved to the class. This still needs to be done.

For loops

For loops not easy to port to Scala, currently done by using a while loop. Using this it is not possible to create a new variable in the for loop that would have the correct scope. (TBD: but this is not possible in Coop anyway??)

Static functions and Scala companion object

Scala classes do not support static variables nor functions. Static members are only allowed in an Scala object. TODO

Continuations

Enabling continuations
(This is not neccesary???? Currently scala delimited continuations are not used to create the CPS style code)
For a project to be able to use continuations they have to be enabled in the Scala compiler. To do this:

  • Go to the project properties
  • Go to Scala Compiler
  • Check "Use Project Settings"
  • In the textbox next to "P" type continuations:enable