Posted by: leppie | August 21, 2009

(ironscheme clr shorthand)

I have moved with-clr-type and friends to the (ironscheme clr shorthand) library.

clr-call, clr-field-get and clr-field-set! have been modified to infer the type based on the instance argument. This is good news, as it allows me to apply with-clr-type‘s shorthand syntax fluidly (or recursively).

To utilize this feature, you simply have to pass #f as the type argument in the macros. Note: This only applies to instance members. For static members, you are still required to provide the type.

The method and indexer syntax has been slightly modified to accommodate this.

The new body syntax is as follows (rest denotes continuable syntax):

(obj : id (arg ...) . rest) ; calls method 'id' with args
(obj : (arg ...) = value)   ; sets the indexer with args to a value
(obj : (arg ...) . rest)    ; gets the indexer with args
(obj : id = value)          ; sets a property 'id' to a value
(obj : id . rest)           ; gets a property 'id'
(obj -> id = value)         ; sets a field 'id' to a value
(obj -> id . rest)          ; gets a field 'id'

;
Example (given the class defined in the previous posting):

(let-clr-type ((obj (TestClass "foo"))) 
  (obj : Message : (1))) ; C#: obj.Message[1]
=> #\o

;
Also added to the (ironscheme clr shorthand) library are define-clr-type and lambda-clr-type syntax, that binds and defines procedures with their arguments tagged as CLR types.

As you can see, now the ability to use .NET libraries should be a lot easier. :)

About these ads

Responses

  1. Easier is good ;)

  2. More coming!

    Working on a macro to do fast dispatching for overloaded methods that cant be resolved at compile time, using a ‘decision tree’ to to resolve types, but still compiling the calls statically and not using slow reflection runtime invocation.


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: