What, again?
Posted May 4, 2007 6:59 UTC (Fri) by
schaueho (guest, #45025)
In reply to:
What, again? by ncm
Parent article:
The Rise of Functional Languages (Linux Journal)
> Yes, Common Lisp, like C, has access to file handles and sockets.
> However, as in C, you cannot abstract management of them. To be very
> precise, if you put a socket in some larger data structure, you must
> explicitly call some cleanup function to ensure it gets closed in a
> timely fashion.
This part confirms my guess that you haven't worked with functional languages in the last five years. In Common Lisp you would write a macro that wraps around any access to your resource and ensures that whatever you need to do after some functionality gets executed (i.e. clean whatever in whatever way up). This *is* the abstraction you would provide to the user of your library/whatever. Just because it's different from what you would do in an imperative language (or make that a "language with explicit memory managment") like C doesn't mean it isn't possible.
> Without the ability to automate such management, exception handling
> facilities are a cruel joke, unable to concentrate error handling in a
> few well-tested spots. Instead, you get "finally" clauses, hundreds or
> thousands of separate snippets of error handling code scattered
> throughout one's program, as hard to exercise as error-code returns, and
> as likely to be wrong.
Take a look at the Common Lisp condition system, it will broaden your view
on "exception" handling a lot.
(
Log in to post comments)