Call .NET Libraries from Lisp Using RDNZL

| by Jonathan Allen Follow 491 Followers on Aug 22, 2007. Estimated reading time: 1 minute |

A note to our readers: You asked so we have developed a set of features that allow you to reduce the noise: you can get email and web notifications for topics you are interested in. Learn more about our new features.

A long standing complaint about Lisp is the lack of high quality libraries. While the truth of this is disputed, there is certainly value in having access to the wide array of libraries found in the .Net platform.

RDNZL gives Lisp programmers access to the .NET library on the Windows platform. While other CLR implementations such as Mono are not currently supported, the maintainers of RDNZL are accepting patches for these platforms.

On the Lisp side, this library support Corman Common List, ECL, Allegro, and LispWorks. Ports for SBCL and GNU CLISP are still in progress.

RDNZL handles the basics like object creation, .NET style arrays, enumerations, boxing, .NET/Lisp type conversions, and the like with relative ease. Method calls can be done in one of two ways. The easiest way is to use the Lisp function invoke, property, or field. These methods use reflection to call the underlying .NET method. To avoid reflection, and cut the call time in half, developers can use define-rdnzl-call to create a Lisp wrapper around the call.

The most serious performance impact from using this library is the cost of marshalling data across. For that reason it is preferable to limit the number of cross-platform calls, and one should especially avoid calling .NET code from Lisp in a tight loop.

Since CLR Callable Wrappers can be easily created for COM libraries, RDNZL also gives developers access to the extensive collection of COM libraries available on the Windows platform. Examples on the link page include calling Excel objects via Microsoft Office automation from Lisp.

Event handlers and other delegates are created by passing in a Lisp closure to the delegate's constructor. One has to be careful about doing this however, as it can create a circular reference that will interfere with both the Lisp and .NET garbage collectors.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Good stuff! by Kurt Christensen

The author of RDNZL (Ed Weitz) has produced some other high-quality stuff. For non-Lispers, I highly recommend his "Regex Coach", a really sweet GUI regex tool, written in Lisp.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

1 Discuss

Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you