Hacker News new | past | comments | ask | show | jobs | submit login

No, I never thought of it. I have no idea what purpose calling the next most specific function would serve. Besides, there are ways to call specific functions other than the best match - like casting the arguments to types that make it an exact match with the desired function.

Despite the power of D's overload mechanism, my advice is to use overloading modestly, not cleverly. You've written your best code when a newbie looks at it and remarks "pshaw, I could have written this! Why does Walter make so much money?"




It's one of those things where on rare occasion where it's applicable it really simplifies the code. Kind of like dynamically scoped variables.

It's been a while that I've hacked CL, but I remember method combinators being used in mixin-style programming[1]. A call-next-method is a simplification tool in that context, and it doesn't hard-couple your generic functions. With concepts now in C++, I wouldn't be surprised to see a resurgence of template-mixins, and there it really helps to have some introspection into the partial ordering.

[1] That is, Flavors mixins, not dlang mixins ;)


Well, I think they should rather react like this: "Wow, so Walter gets so much money because he writes much less convoluted code than what I would have come up with."


They will react that way when they stop being newbies.


Exactly.

Sometimes I think about the advice on how to carve a figure in stone - chip away anything that is not part of the figure.

The same applies to programming. Easy to say, hard to do.


> I have no idea what purpose calling the next most specific function would serve.

This is a replacement for calling the superclass, but it uses C3 method resolution order.


This reminds me that you can get the precedence list in Python with C.__mro__, similar to CLOS's (class-precedence-list C)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: