extending the dynamic typing how-to page
Posted: Tue Jan 13, 2009 11:45 am
I was reading the How-To on dynamic types. At the end, there is a class Notes which uses two "add" methods, one dynamic and the other statically typed, to explain the benefits and drawbacks inherent to each approach. This is all sound, however since Cobra supports generics I think maybe another version of "add" could be added, in which it is implemented as a generic method:
I'm not listing the benefits / drawbacks of this approach because I don't know enough about how generics are implemented in the CLR. My guess would be:
(*) benefits: great flexibility, fast at runtime
(*) drawbacks: code bloat??? slower compilation???
In any case my point is that it might be interesting to extend this How-To page so that it discusses the generics approach as well.
BTW I don't know if Cobra supports generic methods at this stage, but I'm sure it will support them in the future as they are part of C#.
class Notes
# ...dynamic and static versions of add...
def add<of T>(a as T,b as T) as T
return a + b
I'm not listing the benefits / drawbacks of this approach because I don't know enough about how generics are implemented in the CLR. My guess would be:
(*) benefits: great flexibility, fast at runtime
(*) drawbacks: code bloat??? slower compilation???
In any case my point is that it might be interesting to extend this How-To page so that it discusses the generics approach as well.
BTW I don't know if Cobra supports generic methods at this stage, but I'm sure it will support them in the future as they are part of C#.