Programming, Software and Code

Octave update

I've had a little bit of down-time today to work on my octave port, and while I haven't made a lot of progress I'm happy with what is working now. I've spent an inordinate amount of time tracking down bugs which were completely trivial. I don't have the time now to do it, but eventually I want to try to hack in some more descriptive error messages for this thing.

My implementation is small and horribly incomplete, but there are a few things that can be done with it already.

1) I can do simple expressions, assigning to simple scalar variables, etc. Plus, I have (mostly) implemented that particular quirk of MATLAB/Octave where omitting a semicolon at the end of a line causes the result of that expression to be printed. So, if I type "5 + 2", it will print the answer 7. However, if I type "5 + 2;" (notice the semicolon at the end), it won't print anything. This behavior works the way you would expect in most cases, although I need to check for many more corner cases here.
2) Another "feature" of MATLAB (i dont know if this is the same in Octave, although I assume it would be) is that "!" creates a system command. So typing "! echo hello" passes the command "echo hello" to the shell, which prints out "Hello" on the console. Implementing a series of file and directory management operations is going to be a simple extension of this concept, but I haven't bothered to do all that yet
3) Simple built-in functions work as expected. I have not yet implemented a capability to define custom functions in M yet. This is probably the next thing I will work on, although I don't know if I will have time in the next few weeks to do it. I have written a few simple functions like sum() and average() that do things like would be expected. These functions will all have to be rewritten anyway once I implement matrices.

What I haven't done yet is implement control structures like IF, WHILE, and FOR. FOR loops, especially, are dependent on the MATLAB/Octave vector data type, and operate more like the way we would expect a FOREACH loop to work. I have also not yet implemented any kind of exception handleing TRY/CATCH features, because everything raises an exception at this point and there is no point to it. Some of the next few things on my list to do (and again, this is long-term wishing at this point) are:
  1. Polish up what I have currently
  2. Implement functions
  3. Implement conditional operators (I left these out for simplicity, and they shouldn't be too too hard to hack in). With these, I can implement IF and WHILE loops easily.
  4. Implement matrices. This is a doozy because there are no multidimensional datatypes that I can hijack subclass for this purpose. That means i'm going to have to write a custom PMC to do the job. On the bright side, if I do make such a class, we can probably add it to the parrot core so everybody can use it.
  5. Start working on libraries. These can be a combination of PIR and M functions. I also want to try to incorporate the ideosyncratic way that MATLAB searches through the path to find files, and how files are assumed to be named the same as the functions they contain. In short, this means that searching for function "X" is reduced to searching for file "X.m".
After that, I'll have a good portion of the core language implemented, and I can start getting more creative.

After this, it's thesis thesis thesis until the dragon is slain. Ideally, that will be within two weeks. Here's hoping.

This entry was originally posted on Blogger and was automatically converted. There may be some broken links and other errors due to the conversion. Please let me know about any serious problems.