From pfeil at amazon.com Fri Dec 16 01:24:51 2005 From: pfeil at amazon.com (Greg Pfeil) Date: Thu, 15 Dec 2005 17:24:51 -0800 Subject: [cl-containers-devel] Using CL-Containers Message-ID: So, as of today, I'm successfully using CL-Containers at work. Huzzah! A few things I've noticed: 1. I couldn't find an easy way to get an element count for a container. 2. I couldn't find an intuitive way to reverse a list. My solution was: (make-container 'list-container :initial-contents prev-cont) which reverses the list for me. I would have assumed that :initial-contents maintains the same order, but that's not the case. 3. I think I misunderstand the way item-at works. I figured that with an ASSOCIATIVE-CONTAINER, I could access nested hashes like: (item-at container "Config" "server" "port") => 80 But what happens is: (item-at container "Config" "---" "---") => # basically ignoring any keys after the first. Requiring something like: (item-at (item-at (item-at container "Config") "server") "port") => 80 Overall, I'm pretty happy with the library, but was hoping that these things could be addressed. Am I looking for the wrong thing? Is this not-yet-implemented functionality? Thanks a lot for this. I'm re-writing a lot of code to use CL-Containers now. Oh, one other thing ... Will the new Moptilities require a new CL-Containers, or is the interface basically unchanged? From gwking at metabang.com Fri Dec 16 15:05:34 2005 From: gwking at metabang.com (Gary King) Date: Fri, 16 Dec 2005 10:05:34 -0500 Subject: [cl-containers-devel] Using CL-Containers In-Reply-To: References: Message-ID: Hi Greg, On Dec 15, 2005, at 8:24 PM, Greg Pfeil wrote: > So, as of today, I'm successfully using CL-Containers at work. Huzzah! Great! > 1. I couldn't find an easy way to get an element count for a > container. The generic function #'size returns the element-count for any container (someday there will be documentation . > 2. I couldn't find an intuitive way to reverse a list. My solution > was: Why would anyone ever want to reverse a list... . There isn't one. Actually, it is sort of strange but I've never wanted to reverse a container in all the time I've been working with them. It is, however, a function that ought to be there. I'll look into adding reverse-container for subclasses of ordered containers. > 3. I think I misunderstand the way item-at works. I figured that > with an > ASSOCIATIVE-CONTAINER, I could access nested hashes like: > > (item-at container "Config" "server" "port") => 80 This actually should work. I'll investigate. > Thanks a lot for this. I'm re-writing a lot of code to use CL- > Containers > now. I'm glad to hear it. > Oh, one other thing ... Will the new Moptilities require a new > CL-Containers, or is the interface basically unchanged? No. There will be some changes in the cl-containers code (so it will need to be refreshed and maybe recompiled) but the interface will stay the same. -- Gary Warren King metabang.com http://www.metabang.com/ -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2367 bytes Desc: not available URL: From pfeil at amazon.com Fri Dec 16 20:53:52 2005 From: pfeil at amazon.com (Greg Pfeil) Date: Fri, 16 Dec 2005 12:53:52 -0800 Subject: [cl-containers-devel] Using CL-Containers In-Reply-To: Message-ID: On 12/16/05 7:05 AM, "Gary King" wrote: > On Dec 15, 2005, at 8:24 PM, Greg Pfeil wrote: > >> 1. I couldn't find an easy way to get an element count for a >> container. > > The generic function #'size returns the element-count for any > container (someday there will be documentation . Jeez, I should have just tried this, rather than looking for it. Thanks. However ... You use 'count' in other places (eg, ELEMENT-COUNTS, COUNT-ELEMENTS) to mean the number of elements, and you have TOTAL-SIZE which looks like it might be related to the in-memory size, rather than the number of elements? >> 2. I couldn't find an intuitive way to reverse a list. My solution >> was: > > Why would anyone ever want to reverse a list... . There isn't > one. Actually, it is sort of strange but I've never wanted to reverse > a container in all the time I've been working with them. It is, > however, a function that ought to be there. I'll look into adding > reverse-container for subclasses of ordered containers. Well, in this case, I'm calling INSERT-ITEM repeatedly, then reversing afterward. Just because I'm used to doing that instead of appending individual elements. >> 3. I think I misunderstand the way item-at works. I figured that >> with an >> ASSOCIATIVE-CONTAINER, I could access nested hashes like: >> >> (item-at container "Config" "server" "port") => 80 > > This actually should work. I'll investigate. I just tried this tiny example: (defparameter conf (make-container 'associative-container :test #'equal)) (item-at! conf "val" "foo" "bar" "baz") (item-at conf "foo" "bar" "baz") And it worked exactly as you said. Here's my guess: I'm not really using a single ASSOCIATIVE-CONTAINER. I keep doing: (let (new-hash (make-container 'associative-container :test #'equal)) (item-at! new-hash "val" "bar") (item-at! primary-hash new-hash "foo")) (item-at primary-hash "foo" "bar") So, it doesn't merge the different containers together. So, I can fix my code to not work this way. That's not a problem. However, it does still leave open whether or not this is what you want. I think merging them would be cool, but you need to be able to do (item-at conf "foo" "bar") And get back an ASSOCIATIVE-CONTAINER, and also do (item-at conf "foo" "bar" "baz") To get back the value. Right now you can only do one or the other, the former if you insert a separate container, the latter if you build it all in one container. Also, being able to mix ASSOCIATIVE- and INDEXED- container types would be awesome. Like: (item-at conf "foo" "bar" 2 "zoob") Akin to (in Perl): $conf->{foo}{bar}[2]{zoob} So yeah. Thanks again. I'll work on rearranging my code a bit.