• entries
    359
  • comments
    237
  • views
    188615

Chasing Windmills Oncemore.

Sign in to follow this  

58 views

I have got it into my head to create a programming language. No idea why really. I am woefully ill-equipped for such an endeavor. I have Moe to work on. And I really should be learning other languages or getting things done.

Alas, my whimsy will heed no logic. And it's not exactly a new language anyways. Basically, I want to extend C# with two features.

1. Interface DuckTyping.

I found out this is already done assuming you've got sufficient permissions without language extension. The basic idea is not requiring an interface to be inherited in order to pass an object meeting its requirements to it.


public interface IFoo {
void foo();
}
public class Bar {
public void foo() { Console.WriteLine("Foo."); }
}
class Program {

static void Main(string[] args) {

IFoo Baz = Duck.Type(new Bar());
Baz.foo();
}
}



A language extension will likely make that casting implicit.

2. Method Improvements

C#'s delegates suck. Typeless delegates are useful (beyond Func<> and Action<>). Expressions look to be useful, but are slightly orthogonal. You still need to give them a delegate and they effectively compile into delegates it seems.

Method signatures should be usable anywhere a Type is needed. Delegates should provide more info/methods to do useful things (like binding/adapting). I imagine this feature will involve tons of gotchas... [method groups don't really exist, lambdas aren't really delegates, delegates aren't inheritable, action and func are limited and not interchangable tmk]


So the general idea is get something that compiles the language to C# as the intermediary language. If it sucks little, then I might play around with the Visual Studio SDK; seems like an amusing thing to do.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now