Re: Extending protocol for maps

2012-07-28 Thread Vinzent
You can implement the clojure.lang.IPersistentMap interface if you want to create your own map type. суббота, 28 июля 2012 г., 8:09:05 UTC+6 пользователь JvJ написал: > > Is there a way to extend whatever protocol is used by Clojure maps (struct > maps, array maps, hash maps, etc.)? -- You rec

Re: Extending protocol for maps

2012-07-27 Thread Baishampayan Ghose
In Clojure (JVM) Maps, etc. are built on top of Java interfaces and not Clojure protocols (yet). And yes, it's quite possible to build your own data-structure that behaves like a map. I will be able to give you a better answer if you explain your exact requirement. Regards, BG On Sat, Jul 28, 2

Extending protocol for maps

2012-07-27 Thread JvJ
Is there a way to extend whatever protocol is used by Clojure maps (struct maps, array maps, hash maps, etc.)? -- 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 memb

Re: Is this a bug? extending protocol on js/Object

2012-01-25 Thread Takahiro
>> How about using (extend-type default ...) ? Is it safe to use it? > Oops, extend-type with default does work and it seems to work well. This is what I am looking for! Thanks. 2012/1/26 David Nolen : > On Fri, Jan 13, 2012 at 1:32 PM, Jozef Wagner > wrote: >> >> How about using (extend-type def

Re: Is this a bug? extending protocol on js/Object

2012-01-25 Thread David Nolen
On Fri, Jan 13, 2012 at 1:32 PM, Jozef Wagner wrote: > How about using (extend-type default ...) ? Is it safe to use it? > > Oops, extend-type with default does work and it seems to work well. David -- You received this message because you are subscribed to the Google Groups "Clojure" group. To

Re: Is this a bug? extending protocol on js/Object

2012-01-13 Thread Dave Sann
Now I understand...that makes sense - thanks, D -- 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: Is this a bug? extending protocol on js/Object

2012-01-13 Thread David Nolen
On Fri, Jan 13, 2012 at 1:32 PM, Jozef Wagner wrote: > How about using (extend-type default ...) ? Is it safe to use it? The question is how to implement that efficiently. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send

Re: Is this a bug? extending protocol on js/Object

2012-01-13 Thread Jozef Wagner
How about using (extend-type default ...) ? Is it safe to use it? -- 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 you

Re: Is this a bug? extending protocol on js/Object

2012-01-13 Thread David Nolen
It could create interop problems with other JavaScript libraries (including Google Closure). extending Object modifies its prototype. The problem is that objects are used as maps in JavaScript and these new properties will appear if someone tries to iterate through the keys with for..in. It's unfo

Re: Is this a bug? extending protocol on js/Object

2012-01-13 Thread Dave Sann
Ok, I had assumed from this https://groups.google.com/d/topic/clojure/KQ6AM-nxlTQ/discussion that I could Is there anything else not safe to extend? Cheers D -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to c

Re: Is this a bug? extending protocol on js/Object

2012-01-12 Thread David Nolen
You should never extend js/Object. On Thursday, January 12, 2012, Dave Sann wrote: > code is below. > Basically - if I extend a protocol on js/Object then I get an error when calling map on a map with integer keys. > Is this a bug or an error on my part? > Cheers > Dave > Results first: > If the

Is this a bug? extending protocol on js/Object

2012-01-12 Thread Dave Sann
code is below. Basically - if I extend a protocol on js/Object then I get an error when calling map on a map with integer keys. Is this a bug or an error on my part? Cheers Dave Results first: If the extend-protocol and call to 'fred' is commented, ths console shows "START" "one" ([2

Re: extending protocol

2010-03-13 Thread Konrad Hinsen
aria42 a écrit : Is there a way to say that a protocol extends another protocol or interface? I.e. can i specify that a given protocol must also support the "seq" method from clojure.lang.Seqable? No. There is no hierarchy to protocols. This fits pretty well with the dynamic nature of Clojure,

extending protocol

2010-03-13 Thread aria42
Is there a way to say that a protocol extends another protocol or interface? I.e. can i specify that a given protocol must also support the "seq" method from clojure.lang.Seqable? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group,