C#3.0 is looking sweeeet!
ktr wrote:
// to this (C# 3) ------------------------------------
button1.Click += (sender, e) => doSomething();
// i think you can do that ^ ... lol
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
ktr wrote:
// to this (C# 3) ------------------------------------
button1.Click += (sender, e) => doSomething();
// i think you can do that ^ ... lol
Excellent video!
I downloaded the C# code and took a quick look.
Good work with the runtime proxy generation. Geez, it must have been painful writing all that emit IL code!
I'll take a look at writing some Nemerle macros to make the syntax nice. I'm thinking macros along the lines of:
foo = atomic(Foo(arg1, arg2))
<==>
foo = XAction.MakeFactory(typeof(Foo)).Create(arg1, arg2) : Foo;
-------------------------
atomic(foo.Bar(x,y,z))
<==>
XAction.Run(XStart(foo.Bar), x, y, z);
--------------------------
retry
<==>
XAction.Retry();
--------------------------
y = attempt { Get1, Get2 } (arg1, arg2)
<==>
y = XAction.Run(XAction.OrElse(new XStart(Get1), new XStart(Get2)), arg1, arg2) : int;
y = attempt {Get1, Get2, Get3} (arg1, arg2)
<==>
y = XAction.Run(XAction.OrElse(XAction.OrElse(new XStart(Get1), XAction.OrElse(new XStart(Get2), new XStart(Get3)))), arg1, arg2) : int;
John Melville, MD wrote:
In C# 3.0 I think you can build 95% of this with extension methods, like this:namespace DoDynamic { public static class DoDynamic { public static object call (this object s, string name,
param object[] parameters) { // find and call the function using reflection } } }
Your sample becomes:
void Test()
{
object foo = GetData(); // "late" is a new, psuedo-type, keyword.
foo.Call("DoSomething");
}.
In adddition to being doable with the next c# as it is currently specified this syntax also makes the dynamic nature of each
call plainly obvious, and it is possible to chose dynamic or static on a per call, rather than a per-object basis.
Not exactly what you asked for, but pretty close and already working (in beta builds.)
androidi wrote:
Andrew Davey wrote:
So in C# I'd love to see:
void Test()
{
late foo = GetData(); // "late" is a new, psuedo-type, keyword.
foo.DoSomething();
}
How is this different from how LINQ uses C# 3.x for example? It's not RTM yet which is too bad yeah.
Do people see VB's inherent verbosity getting the in way of implementing features, like lambda expressions, in way that won't confuse Mort?
In C# 3.0:
list.Where(x => x == 42)
is nice and succint.
I've not been able to find a VB 9 version of that yet. The VB future's website still uses "AddressOf" to a seperate function.
Does anyone know what the anonymous method/closure/lambda expression syntax looks like in VB 9?
Adding late binding to C# could be done easily if they copied Boo. In Boo you can declare a variable "as duck". Then any references to members on that variable are late-bound. I like the approach because it makes the declaration explicit.
def Foo():
x as duck = GetSomething()
print x.Bar()
Note that it's duck as in "duck typing".
Where it gets more awesome is if you implement the IQuackFu interface on a class. This interface defines three methods: QuackInvoke, QuackGet and QuackSet. So when calling code invokes any member on your class, the compiler actually makes it call the dispatcher
methods of the interface, passing the member name and arguments.
This basically means you can do funky stuff like add methods at runtime to a class. See
http://docs.codehaus.org/pages/viewpage.action?pageId=13653 for a cool dynamic mixin example.
Adding this feature to C# would not in any way affect normal early-bound code. People are free to ignore the feature, but it's there if they really need it (e.g. with COM interop).
Adding support for something like IQuackFu (changing to a less silly name too I bet!) would actually surpass VB's dynamic abilities.
So in C# I'd love to see:
void Test()
{
late foo = GetData(); // "late" is a new, psuedo-type, keyword.
foo.DoSomething();
}
Minh wrote:I'm curious - why not implement this as a library on top of multi - core CPU's (which seems a much moreuseful Scenario) rather than a GPU ?
(or perhaps You find the limited Ps instruction set easier to start out with)