On 23 Apr, 2006, at 11:26 am, Alberto Valverde wrote:
Also I should note that you don't *need* to undersand how they work in order to *use* them.

On the other hand, if you need to understand the code that uses them, you'll NEVER actually know what the code does unless you understand EVERY instance of the generic function. It's impossible to look at the following code any actually know what it does:

@generic()
def flip_the_frobble(obj):
pass

...

def clever_function(obj):
flip_the_frobble(obj)

What does clever_function actually do? It's impossible to tell, because you have no idea what versions of the generic flip_the_frobble have been created.

When languages like C++ offer function overloading, they do it via type inspection. So you can very clearly understand whether the function will be invoked. However, generic functions have no such limitations. I've heard lots of arguments touting that generic functions increase the flexibility of code, and that's certainly true. However, no one has every cited an example that can only be achieved using generic functions. I've yet to hear an explanation similar to: "I've been looking for a way to flip my frobbles for ages, and thanks to generic functions, I now can!"

No. I'm afraid I classify generic functions under "leads to bad software design".


--
Jeff Watkins

"We're growing the government at a pace that makes Democrats look thrifty."
-- Senator Lindsey Graham, (R) South Carolina



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to