Re: What's up with IMeta?

2017-11-05 Thread James Reeves
On 5 November 2017 at 21:32, Michał Marczyk wrote: > Now, if xs' head has not been realized, (with-meta xs {:foo 1}) can > conceivably operate in one of two ways: > > 1. it can copy over xs' thunk (the nullary function embedded in the lazy > seq object xs that is called

Re: What's up with IMeta?

2017-11-05 Thread Michał Marczyk
About realizing the head of lazy seqs in with-meta: On 5 November 2017 at 01:57, Didier wrote: > > That said, metadata and its relationship to an object is immutable - an >>> object with different metadata is a different object. One consequence of >>> this is that applying

Re: What's up with IMeta?

2017-11-04 Thread James Reeves
On 5 November 2017 at 00:57, Didier wrote: > I think I'm firstly confused by the use of the word object. I'm guessing > in this case it refers to things that implement IObj? > It means an object on the JVM. > I'm then confused by what is meant that an object with different

Re: What's up with IMeta?

2017-11-04 Thread Justin Smith
first class values on the jvm are objects On Sat, Nov 4, 2017 at 5:57 PM Didier wrote: > > That said, metadata and its relationship to an object is immutable - an >>> object with different metadata is a different object. One consequence of >>> this is that applying metadata

Re: What's up with IMeta?

2017-11-04 Thread Didier
> > > That said, metadata and its relationship to an object is immutable - an >> object with different metadata is a different object. One consequence of >> this is that applying metadata to a lazy sequence will realize the head of >> the sequence so that both objects can share the same

Re: What's up with IMeta?

2017-11-04 Thread James Reeves
On 3 November 2017 at 06:57, Didier wrote: > Okay, I can see how I can maybe infer some of that by piecing together the > code base, but if there was a book, or a reference somewhere describing > more the implementation of Clojure itself I'd be interested to read it, if >

Re: What's up with IMeta?

2017-11-03 Thread Didier
Okay, I can see how I can maybe infer some of that by piecing together the code base, but if there was a book, or a reference somewhere describing more the implementation of Clojure itself I'd be interested to read it, if there is one out there. I'd understand if there's not, I know Clojure has

Re: What's up with IMeta?

2017-11-02 Thread James Reeves
On 3 November 2017 at 02:31, Didier wrote: > Wow, thanks. Is that all tribal knowledge? Or is there some documentation > around the Clojure interfaces and their semantics somewhere I could read? > Maybe even a Clojure book recommendation that covers this? > Each of the

Re: What's up with IMeta?

2017-11-02 Thread Didier
Wow, thanks. Is that all tribal knowledge? Or is there some documentation around the Clojure interfaces and their semantics somewhere I could read? Maybe even a Clojure book recommendation that covers this? So if I understand correctly, withMeta will return a new object which is not equal to

Re: What's up with IMeta?

2017-11-01 Thread Alex Miller
+1 to everything James said. -- 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 unsubscribe from

Re: What's up with IMeta?

2017-11-01 Thread James Reeves
IMeta only allows you to read metadata. IObj is for immutable data that can be duplicated with new metadata. IReference is for references. So an immutable map would implement IObj, but an atom would implement IReference. If you want to support metadata, you need to decide what type of object it

Re: What's up with IMeta?

2017-11-01 Thread Timothy Baldridge
To start with, IObj and its .meta method are used with clojure.core/meta to get the metadata on an object. Since this method can be the same between refs and immutable data, they all use the same interface. IMeta is used with withMeta and clojure.core/with-meta to return a new object with the

What's up with IMeta?

2017-11-01 Thread Didier
Hey, I was surprised to find that IMeta does not work for (with-meta). So it seems that withMeta is added to IObj, which extends IMeta. And it seems like alterMeta and resetMeta are added in IReference, which also extends IMeta. So now if you want to support meta, you have to implement