Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This issue of where to place functions is something I have been curious about, too.

In the Lisp community, what are the standards for where to store your generic methods as opposed to defined classes they work with? Rephrased, if I define classes Foo and Bar, and I write generic method foobar (accepts as params instances of Foo and Bar), where do I put foobar?

In the C++ world, where should I put my friend functions that suffer a similar lack of obvious home?

I have often seen solutions where some package/class is chosen arbitrarily as the "proper" home for these cross-class communicators, but I have long felt like this is a compromise rather than good organization. And yes, I recognize that there are at least two kinds of organizations: In what file is my code? In what namespace is my code? I am concerned with the namespace aspect.



>Rephrased, if I define classes Foo and Bar, and I write generic method foobar (accepts as params instances of Foo and Bar), where do I put foobar?

This sounds similar to the expression problem.

http://www.infoq.com/presentations/Clojure-Expression-Proble...


Generics/friends/multimethods are one of the solutions identified on the slides you posted (and protocols are interesting), but I did not see mention of appropriate namespaces for these.




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

Search: