Re: Protocol methods, name shadowing and dot notation

2012-09-03 Thread VĂ­ctor M . V .
Oh, I understand. Works in ClojureScript as well! I noticed that in this line (protocols/get [_] 42) One can safely drop the namespace qualification. Thank you very much Matthias - this issue was certainly a blocker for me. On Mon, Sep 3, 2012 at 5:54 PM, Matthias Benkard wrote: > You have re

Re: Protocol methods, name shadowing and dot notation

2012-09-03 Thread Matthias Benkard
You have reused a name already bound in the `protocols` namespace. You cannot bind two things to the same var. On the other hand, precisely because namespaces are not complected with protocol dispatch, you can easily free the `get` identifier for your purposes by doing exactly what you would do

Re: Protocol methods, name shadowing and dot notation

2012-09-03 Thread vemv
Hi Matthias, I can't disagree with you, and am open to change my mind. Just a question. Given again this example: (ns protocols) (defprotocol P (get [_])) (ns app) (defrecord R [] protocols/P (get [_] 42)) (can you call R's get without resorting to dot-notation, this is, with a na

Re: Protocol methods, name shadowing and dot notation

2012-09-03 Thread vemv
Would it be feasible to efficiently make them first class? Surely this isn't a new question, as many would desire to write (mapv .toString (range 10)) rather than (mapv #(.toString %) (range 10)). Couldn't find info on that topic... *(just an example, I know there's str) On Monday, September 3

Re: Protocol methods, name shadowing and dot notation

2012-09-03 Thread Matthias Benkard
Hi, In principle, dispatch is orthogonal to namespacing. It is true that traditional OO systems complect these two things, but there is no inherent need to do so. Separating dispatch (i.e., methods) from namespacing is simpler and more flexible. This is especially useful when you have multip

Re: Protocol methods, name shadowing and dot notation

2012-09-03 Thread Ambrose Bonnaire-Sergeant
On Mon, Sep 3, 2012 at 9:17 PM, vemv wrote: > At least from the point of view of someone that isn't too familiar with > the Clojure internals, I see no downsides - although I tried it! For > instance, given that one can call (.first ()), I thought that then one > could call (.first (ARecord.)), w

Re: Protocol methods, name shadowing and dot notation

2012-09-03 Thread vemv
Correction: records/types actually include plenty of dot-accesible methods, though less than lists -for instance- do. (mapv println (.getMethods (.getClass (ARecord. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send em

Protocol methods, name shadowing and dot notation

2012-09-03 Thread vemv
Hello there, I'm not quite sure whether is convenient for each method implementation to possibly shadow previous names, particularly those of clojure.core. (defprotocol Example (get [this])) The previous example redefines get in the current namespace. But is that we usually mean by "me