Re: multimethod, record, type, and protocol pitfalls?

2014-11-11 Thread Justin Smith
Helping newcomers to the language on #clojure, I often find the need to use a protocol in reference to it's namespace rather than the namespace of the datatype extending it is a counter-intuitive one for people learning the language. Similar with dispatch methods. Speculatively, I think it has

Re: multimethod, record, type, and protocol pitfalls?

2014-11-05 Thread Adam Krieg
My experience with protocols is that the implementations can't be redefined, e.g changing an implementation. So if you change one of the applied protocols, you may need to restart your REPL. YMMV. Using records outside of their declared namespace is also really weird. You need to both

Re: multimethod, record, type, and protocol pitfalls?

2014-11-05 Thread Gary Trakhman
You don't need to import the record if you use the auto-gen'd factories, -RecordName and map-RecordName. You can and also shouldn't import the java interfaces created by protocols. It's possible to interactively develop this way, but you really have to know what's being eval'd and what types are

Re: multimethod, record, type, and protocol pitfalls?

2014-11-05 Thread Adam Krieg
You are right about the factory methods for Records. My need to reference the records in another namespace was for type hinting. On Nov 5, 2014, at 6:12 PM, Gary Trakhman gary.trakh...@gmail.com wrote: You don't need to import the record if you use the auto-gen'd factories, -RecordName

Re: multimethod, record, type, and protocol pitfalls?

2014-11-02 Thread kovas boguta
Heres one thing: https://groups.google.com/forum/#!topic/clojure/ILPz4QOEod8 Requiring the namespace where you declared the type is not enough, you need to import the type separately if you want to avoid using the fully-qualified name. There is also a difference in this behavior between clojure

Re: multimethod, record, type, and protocol pitfalls?

2014-11-02 Thread kovas boguta
Maybe the most confusing thing is which construct to use when. I've found the following posts to be pretty helpful in sorting out the different tradeoffs: https://github.com/Prismatic/eng-practices/blob/master/clojure/20130926-data-representation.md

Re: multimethod, record, type, and protocol pitfalls?

2014-11-01 Thread Daniel Higginbotham
Thanks for the responses! This is very helpful. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To

Re: multimethod, record, type, and protocol pitfalls?

2014-10-27 Thread Sven Richter
Hi Daniel, When running through tutorials and blog posts it did not occur to me that the functions of a defprotocol are namespaced to where they are defined. Meaning, calling these functions I have to use their original namespace. It is obvious when one reads the official documentation, but one

Re: multimethod, record, type, and protocol pitfalls?

2014-10-27 Thread Gary Verhaegen
As recently mentioned on another thread, this also means that you cannot have two different protocols with the same method names in the same namespace. This may be surprising, especially from an OO background, where it is very natural to have two types with the same operations. On Monday, 27

Re: multimethod, record, type, and protocol pitfalls?

2014-10-27 Thread Daniel Higginbotham
These responses are all super helpful, thank you! I'd love to hear more pitfalls/pain points if anyone else wants to share. Thanks! Daniel On Monday, October 27, 2014 6:59:43 AM UTC-4, Gary Verhaegen wrote: As recently mentioned on another thread, this also means that you cannot have two

Re: multimethod, record, type, and protocol pitfalls?

2014-10-27 Thread larry google groups
The differences between OOP and multimethods should be stressed. I just wrote about this on my blog, and those who mostly worked with OOP kept wondering, how do you get inheritance of functionality? Actually, they did not ask this clearly, so it took me awhile to understand their question,

multimethod, record, type, and protocol pitfalls?

2014-10-27 Thread Gary Verhaegen
It has not been a pain point for me so far, but there is one more thing that may be somewhat surprising: multimethods and protocols introduce non-locality into the code. This means that, with code that uses multimethods or protocols, sometimes requiring a namespace and not using any symbol from

Re: multimethod, record, type, and protocol pitfalls?

2014-10-27 Thread Rogerio Senna
On Mon, Oct 27, 2014 at 2:21 PM, larry google groups lawrencecloj...@gmail.com wrote: ​ The differences between OOP and multimethods should be stressed. I just wrote about this on my blog, and those who mostly worked with OOP kept wondering, how do you get inheritance of functionality? ​

Re: multimethod, record, type, and protocol pitfalls?

2014-10-27 Thread Raoul Duke
Notice that he intentionally left inheritance out from that definition. there are more connotations of object oriented than there are quills on a porcupine. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: multimethod, record, type, and protocol pitfalls?

2014-10-27 Thread Rogerio Senna
On Mon, Oct 27, 2014 at 4:13 PM, Raoul Duke rao...@gmail.com wrote: Notice that he intentionally left inheritance out from that definition. there are more connotations of object oriented than there are quills on a porcupine. ​Sure. But since Alan Kay is the guy who invented the term object

Re: multimethod, record, type, and protocol pitfalls?

2014-10-27 Thread larry google groups
​First of all, let me state that I'm a complete Clojure noob. Still, I thought that Clojure's multimethods were a completely valid OOP approach. ​ Q ​uoting Alan Kay: When I have made that point (about Alan Kay's vision) to certain OOP evangelists, I have been told that Alan Kay's vision

Re: multimethod, record, type, and protocol pitfalls?

2014-10-27 Thread Jason Wolfe
Not sure if this is exactly what you're looking for, but there might be some relevant info here: https://github.com/Prismatic/eng-practices/blob/master/clojure/20130926-data-representation.md Comments/suggestions/questions welcome. -Jason On Sunday, October 26, 2014 8:48:29 AM UTC-7, Daniel