News for hackers. Stuff that matters.
Re:Thoughts on Python 3 by Jach on Wednesday December 07, 2011 @05:36AM (#3323269)
I like the Clojure form of multimethods a lot, it's even neater than CLOS. ( http://clojure.org/runtime_polymorphism )

C's dynamic dispatch hack isn't so terrible though--e.g. Microsoft has been doing it for a long time by sticking in a "useless" instruction at the start of every function. http://blogs.msdn.com/b/oldnewthing/archive/2011/09/21/10214...

Re:Thoughts on Python 3 by frio on Wednesday December 07, 2011 @02:44PM (#3325543)
Just for my own sanity - is "multimethod" another term for a form of pattern matching? Looking at the clojure code, it strongly reminds me of Haskell:

  encounter :: Species -> Species -> Result
  encounter (Bunny _) (Lion _) = RunAway
  encounter (Lion _) (Bunny _) = Eat
etc. Of course, pseudocode, syntax errors, whatever - but it looks to be the same idea?

edit - formatting

Re:Thoughts on Python 3 by thurn on Wednesday December 07, 2011 @05:37PM (#3326485)
A key difference is that Haskell functions can only have one type signature, so you need to explicitly make "Bunny" and "Lion" data constructors for "Species". Multimethods operate on multiple types. You can fake multimethods in Haskell with multi-parameter type classes (with the language extensions to allow undecidable and overlapping instances).
Re:Thoughts on Python 3 by frio on Wednesday December 07, 2011 @06:59PM (#3326819)
I see. Thanks!
Re:Thoughts on Python 3 by Jach on Thursday December 08, 2011 @06:45AM (#3328710)
Rich Hickey actually commented on the difference between multimethods and pattern matching here: http://sadekdrobi.com/2009/05/27/multimethod-in-clojure-shou...

(Here's a pattern matching module I know of: https://github.com/brool/clojure-misc )

Re:Thoughts on Python 3 by arethuza on Wednesday December 07, 2011 @05:44AM (#3323286)
Does Clojure do method combinations? I was very fond of :before, :around and :after methods of the standard method combination and loved the fact that, if you really wanted to, you could have your own method combinations.

I know that "Aspect Oriented" tools support some of this stuff, but the last time I looked at those (admittedly a while ago) they seemed, at least for Java, to be pretty hacky. Not that I use Java anymore...

Re:Thoughts on Python 3 by Jach on Thursday December 08, 2011 @06:58AM (#3328734)
Clojure doesn't implement those out-of-the-box, but there might be a contrib module somewhere macroing it in... I think they're petty neat too.