deft flux

A portal into the creative workings of David Meyer

About the author

David Meyer (a.k.a. "deft flux") is a software developer fluent in C#, C++, Java and others. He also programs in his spare time and enjoys playing instruments and making electronic music.
E-mail me Send mail

Recent posts

Recent comments

Authors

Disclaimer

The opinions expressed by the author are his alone and do not represent any other person or organization unless stated otherwise. The opinions given in comments are solely those of the person who wrote the comment and are not necessarily the opinions of the author of this site. The author of a post is not responsible for the content of its comments.

© Copyright 2008
David Meyer

Duck Typing version 0.9.30 released

Binaries: DuckTyping_0.9.30.zip (125.01 kb)
Source: DuckTyping_0.9.30_Source.zip (36.86 kb)

The static page explaining the duck typing project can be found here.

  • Fixed: A stack overflow no longer occurs when a duck casting conversion infers the same duck casting conversion.
  • Added: Some support for generic methods, but do not expect it to be bug-free.  I had to release it in this state so that the above bug fix would be released.  It should not affect other kinds of class members, though.

Sorry, but comments still don't work...  I'm working on it...

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by deftflux on Monday, September 10, 2007 12:29 PM
Permalink | Comments (3) | Post RSSRSS comment feed

Related posts

Comments

KShaban us

Monday, March 24, 2008 6:55 PM

Gravatar

Hi,

First, this library definetly fills a few big needs.

However, I can not seem to get the static duck typing to work.

I am trying a very simple example in isolation setup as:

public interface iContract
{
object Create();
}

public class SomeClass
{
public static object Create()
{
return(new object());
}
}

I then run the following code:

iContract poContract = (iContract)DuckTyping.StaticCast(typeof(iContract), typeof(SomeClass));
var poNew = poContract.Create();

The call poContract.Create() blows-up with:
System.MethodAccessException: TEST.CW.ObjectScope.SomeClass.Create().

DuckProxy.Create()
CW.ObjectScope.cw_ScopeBase.Create(Type typCreate) in B:\Dev\1_NEW\CW.Frame\CW.ObjectScope\cw_ScopeBase.Creation.cs: line 30

Any ideas what I doing wrong?

Many Thanks,

Kavan

KShaban us

Monday, March 24, 2008 7:07 PM

Gravatar

Hi Again,

Got it working!

Seems the problem was that implementation class 'SomeClass' was not marked as public.

This was causing the MemberAccess exception.

As a side question, why does it matter since the DuckTyper is binding right to the method. And if it is necessary that the implementation class be public should there not be some runtime checks?

Anyways this library really rocks, I just wish I had found this a few months ago.

You should consider posting this on CodeProject.

Thanks a bunch,

Kavan

Paddy3118 gb

Sunday, April 27, 2008 12:18 AM

Gravatar

Hi David,
I think your library is doing structural typing rather than Duck typing. The Wikipedia Duck Typing article shows the difference between the two, and in the articles discussion page, the 'class DuckDecoy' example shows something that works under Duck Typing but would not under Structural Subtyping.

- Paddy

Add comment


(Will show your Gravatar icon)  

  Country flag




Live preview

Thursday, August 21, 2008 2:56 AM

Gravatar