InfoQ

News

Call .NET Libraries from Lisp Using RDNZL

Posted by Jonathan Allen on Aug 22, 2007 06:41 AM

Community
.NET
Topics
Interop
Tags
LISP

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.

2 comments

Reply

Good stuff! by Kurt Christensen Posted Aug 22, 2007 11:18 AM
Re: Good stuff! by Fergal Dalton Posted Nov 7, 2007 12:31 PM
  1. Back to top

    Good stuff!

    Aug 22, 2007 11:18 AM 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.

  2. Back to top

    Re: Good stuff!

    Nov 7, 2007 12:31 PM by Fergal Dalton

    i have used Regex Coach also its an excellent tool highly recomment it. Fergal. Online Courses, Training Courses, Elearning

Exclusive Content

Agile in Practice: What Is Actually Going On Out There?

Scott Ambler talks about actual data resulting from surveys made during 2006-2008, showing how Agile is perceived and implemented within organizations.

Building Smart Windows Applications

From QCon 2008, Daniel Moth presents on using Visual Studio 2008 and .NET 3.5 to create compelling rich Windows applications.

Joshua Kerievsky about Industrial XP

Joshua Kerievsky, founder of Industrial Logic, talks about Industrial Extreme Programming which extends XP by including practices dealing with management, customers and developers.

Jeff Barr Discusses Amazon Web Services

Amazon Web Services (AWS) Evangelist Jeff Barr discusses SimpleDB, S3, EC2, SQS, cloud computing, how different Amazon services interact, origins of AWS, AWS globalization and the March AWS outage.

More Than Just Spin (Up) : Virtualization for the Enterprise and SaaS

Cloud services have helped bring virtualization to the forefront. Its full power however, also includes other benefits such as high availability, disaster recovery, and rapid provisioning.

Ruby Beyond Rails

John Lam talks about his path to dynamic languages, some of the problems of making IronRuby run fast, and how the DLR helps with implementing languages.

VMware Infrastructure 3 Book Excerpt and Author Interview

VMware Infrastructure 3: Advanced Technical Design Guide and Advanced Operations Guide provides a wealth of practical insights into setting up virtualization in todays corporate environments.

Architectures of extraordinarily large, self-sustaining systems

Can a system that is so large it cannot be comprehended be "designed" in a conventional sense? The foundations of computing are about to change. In this talk, Richard P. Gabriel explores why and how.