Skip to content

Extending deftype and company for CLR

dmiller edited this page Sep 13, 2010 · 12 revisions

A work in progress

A contemplation

Clojure has been adding a variety of new methods for defining types and interfaces, either directly or indirectly. Here’s a list:

  • proxy
  • gen-class
  • gen-delegate (CLR only)
  • gen-interface
  • definterface
  • reify
  • deftype
  • protocol

Although ClojureCLR has implementations of the all of these, the implementations are at present inadequate to handle the full complexity of method signatures that the CLR presents.

Expressing just a bit of envy: the biggest complexity that the JVM seems to offer here are covariant return types. Some of the functions above are forced to define bridge methods to handle this. ClojureJVM developers should appreciate this more.

Here’s what needs to be handled on the CLR side:

  • properties
  • by-ref parameters (in and out params in C#)
  • explicit interface implementation
  • true generics

I have handled properties and by-ref parameters properly in host expressions.

I have handled none of these in the functions above.

I have some proposals and some questions.

Clone this wiki locally