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:
- Polish up what I have currently
- Implement functions
- 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.
- Implement matrices. This is a doozy because there are no multidimensional datatypes that I can
hijacksubclass 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. - 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 this, it's thesis thesis thesis until the dragon is slain. Ideally, that will be within two weeks. Here's hoping.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.