LWN.net Logo

Advertisement

Front, Kernel, Security, Distributions, Development. See your byline here on LWN.net.

Advertise here

What, again?

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)

No

Posted May 9, 2007 5:37 UTC (Wed) by ncm (subscriber, #165) [Link]

1. You haven't been reading carefully.

2. You are mistaken; Lisp does in fact lack the important capability I identified. Of course it is only important in industrial work, and not in academic demonstrations. You haven't missed it. I certainly would.

3. Your attitude is common among Lisp fans, and suffices to explain why Lisp has not gained a foothold in industrial programming despite fifty years' promotion in academia.

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds