[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Error handling and IO

From: Alexey Veretennikov
Subject: Re: [Bug-apl] Error handling and IO
Date: Sun, 10 Apr 2016 17:49:46 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.91 (darwin)


In Dyalog APL there is a mechanism similar to try/catch in other

R←f X
:Trap 0
    ⎕←'Error happened'

      f 0
Error happened

For details see the Mastering Dyalog Apl
(http://www.dyalog.com/uploads/documents/MasteringDyalogAPL.pdf) Chapter M: 
Event Handling

Elias Mårtenson <address@hidden> writes:

> 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]