Yesterday, I participated in the Google Code Jam (programming competition). For one of the tasks, APL was a very good fit. The question is here:
https://code.google.com/codejam/contest/6254486/dashboard#s=p1
My solution (which I will not post right now, since one of you might want to give it a shot first) was terse and simple. A very simple APL _expression_.
However, reading the input a file and formatting the result took many lines of very ugly code.
This attempt at using APL to solve a real-world programming problem illustrated two separate issues that, needs to be handled:
Firstly, the FILE_IO library is way too low-level. For example, in the Codejam tasks, one usually have to read a whitespace-limited sequence of numbers. When I solve the problems in Lisp, all I need to do is to call READ. A flextible IO probrary that makes these kinds of this simple would be nice.
I could (and indeed have considered to) write such functions in APL, but this causes a second problem:
Error handling in GNU APL is very bad. In particular, there is nothing similar to UNWIND-PROTECT (or try/finally in Java). There is no way to safely write code that opens a file, works on it and then closes it. If an error occurs, there is no way to ensure that the filehandle is closed. When I developed my solution to the Codejam problem, I ended up leaking a lot of file handles.
Does anyone know how Dyalog and other vendors handle this? Do they have a full exception system?
Regards,
Elias