Question

I am currently writing a program using matlab in scala (via the matlabcontrol API). I want to achieve a programming language independent solution, so I can use some algorithms in Scala and some in Matlab. The program works already (as far as I tested it) but I am also interested in abstraction so that I can exchange modules using scilab or other languages.

To understand the problem in detail I show you the ImageReader class:

trait ImageReader {
  def readImage(path:String):Any
}

object Matlab_ImageReader extends ImageReader {
  def readImage(path:String):Any = {
     proxy.eval("image = imread('"+ path + "');"
     return "image"
  }
}

The idea is, that I want to treat the return value as a reference to the language object I use. I will use Scala only as a controler, working with references and thereby implementing a partwise object-oriented solution for a complicated piece of matlabcode.

Now I also want to exchange parts of the code and give other developers a possible entrypoint for implementing their own solution for example in Scala. The problems are:

  1. How to return a concrete and mutual Datatype, so I can use the method knowing I will always have the same return-type?
  2. How to get a reference to a value in Scala? It would help me a lot as I may be able to abstract it this way.

I am sorry for the vague question, but I do not really know how to explain my exact problem :)

Was it helpful?

Solution

Probably you should look at Lightweight Modular Staging and Scala Virtualized.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top