Dharma Shukla: Inside Live Framework
oChart.ChartWizard( oResizeRange, Excel.XlChartType.xl3DColumn, Missing.Value,[[ becomes ]]
Excel.XlRowCol.xlColumns, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value );
oChart.ChartWizard(
Source : oResizeRange,
Gallery : Excel.XlChartType.xl3DColumn,
PlotBy : Excel.XlRowCol.xlColumns
);
I'm half way through, and I have a question.
Say you have the following:
dynamic x = ...
x.M(1,2,3,4,5,6,7,8,9,10);
x.M(1,2,3,4,5,6,7,8,9,"a string");
x.M(1,2,3,4,3.14159);
x.M(DateTime.Now);
Will the generated delegate check parameters one at a time? eg, like this:
if (param1Type == typeof(int))
{
if (param2Type == ...)
{
...
if (param5Type == int)
{...}
else if (param5Type == double)
{ ..}
} else if (param1Type == DateTime) {}
Or will it check each one repeatedly?
Also, will there be any sort of profile-guided optimisation in that delegate? Say that it notices x.M(DateTime) is called the most, will it reorder the tests?
I'm wondering what influence the optional and named parameters will have on interfaces and inheritance in general. Will a method parameter have to have the same name in an implementation as in the interface? This would help for code quality and maintainability.
If not, will the compiler keep track of how a parameter gets renamed in the inheritance hierarchy or do all signatures get treated individually? Can a non optional parameter be made optional in an inherited method? What about the other way round?
One more question: when will C# get XML literals like Visual Basic? I've been waintig for this since Comega...
Wolfgang
Ive worked a good amount between C# and COM. Optional parameters are nice, but i've found ways to work without them. I think allowing reordering of parameters is only asking for trouble. Especially in the talk the first thing talked about with this feature is how developers can screw themselves. I think it weakens the language to let things blow up at runtime rather than compile time.
Great that these things are possible but I don't plan on using them.
ive got a question about the method caching in the dlr..
what if the arguments of a method is of type dynamic? lets say ive got a ruby int and a ruby string and i pass that into a ruby method M, all from c# (by calling libraries written in ruby for instance)
how would the dlr cacher handle that? both the arguments whould be dynamic but actually contain diffrent types..
im pretty sure the dlr handles it but it would be fun to hear more about that ![]()
awsome work as always charles ![]()
C# 4.0 is great and all, but HOW DO I GET ONE OF THOSE T-SHIRTS!!!
Regarding the complexity of overload resolution, it doesn't seem quite as bad as made out in the show (espcially compared to writing the compiler in the first place)
Please note I am assuming you can't mix named and non named args in the same call - that would certainly complicate things.
I agree the first thing is to consider the parameter names available to filter out invalid candidates.
Second I would use the types to filter candidates further (considering valid implicit casts and base classes) This didn't seem to be mentioned.
Then I would represent the candidate methods with a integer (with lots of bits) using 1 bit per arg. Turn on these bits for each arg that is matched (by name) in the call. Turn on other bits that do not have an arg supplied in the call if they have a default value.
Compare those integers with a mask representing the number of args in the candidates. Those that have all their args fulfilled remain candidates.
If there is still more than one candiate overload, either throw an error, or have a policy to select the method.
I'd be interested to get comments on this approach.
Apologies if I've opened a can of worms. I've only given this 5 mins thought, but I have also written a complier.
Martin
I agree. I can't imagine what C# 10 will be like.
I agree in part. The neat thing about python is that it is compartmentalized. If you don't need functionality, you don't include it. A language should be extremely simple and elegant. If you need to build a skyscaper, you need a crane. But you build the crane using smaller tools. And you build those tools with basic simple tools. C# has become a do everything Swiss Army knife. I am not saying that C# has become bloatware, but I will say that it is becoming dangerously close to being complex. I have to wonder if that complexity is really necessary, and if it is, whether it is the result of a basic design defect that poses challenges that require the complexity to overcome.
no its gets wonderful and powerfull an programming technology
go on Microsoft add most beatiful things too we are waiting;)
My favorite part about all the new features is that, if you don't like, don't understand, or are frightened by them, you don't have to use them. All your unpolluted old code still works. For my part, I'm really excited to start incorporating a lot of the dynamic tools some of my compatriots have been enjoying for the last few years.
Another interesting article on .NET 4.0 dynamics can be seen here (http://nightowlcoders.blogspot.com/2010/05/building-better-dynamic-net-40.html) This outlines how to take advantage of string based property access across a dynamic object. This is a really powerful combination when put along side other features using Dynamics.
Feel free to re-link and follow!
-Night Owl Coders
You guys are brilliant!
@swingsetacid:
"My favorite part about all the new features is that, if you don't like, don't understand, or are frightened by them, you don't have to use them"
Have you ever worked as a programmer? Maybe YOU don't use them, but then the guy down the hall does, and uses them badly because he doesn't understand them, and next thing you know you're fixing his awful code. At least, that's the source of this fear.
Personally I don't worry much about most of these features, but covariance/contravariance worry me because they remove checks on type safety. I expect my C# code to be type correct as long as I avoid explicit downcasting (and now, the dynamic keyword), but this change to the language violates that expectation because it effectively allows implicit downcasting. And, worse, it allows it using the exact same syntax that I previously expected to be safe.
@spivonious:@nolisj: