Conflict between iterate and cl-containers

Discussion of Common Lisp
Post Reply
wvxvw
Posts: 127
Joined: Sat Mar 26, 2011 6:23 am

Conflict between iterate and cl-containers

Post by wvxvw » Wed Dec 11, 2013 5:37 pm

Hi,

Was wondering about the common practice: which would you do if two packages which you want to use both export the same symbol? (In this case both iterate and cl-containers export "finish").

Using fully qualified iterate names creates really messy code, so I'd probably keep iterate in any event (besides, afaik iterate manipulates symbol-plist, so its important to use its symbols). But stuff like (cl-containers:size var) looks like a mouthful too! :)
So, what would you do, use fully-qualified cl-containers names, or do some exporting-importing-shadowing magic to get nicer looking source? :)

pjstirling
Posts: 166
Joined: Sun Nov 28, 2010 4:21 pm

Re: Conflict between iterate and cl-containers

Post by pjstirling » Thu Dec 12, 2013 7:32 am

Personally, I normally use package names for libraries written by other people, but, like your usage of iterate, parenscript is obfuscated when used in this style, so I have a second package that :USEs parenscript, so I don't need to worry about package contamination in most of my code.

For your case you may want to create a wrapper with a different name in your package, this is actually an area where I think common-lisp is a bit unfortunate: I think you should be able to import symbols into a package under another name than its SYMBOL-NAME, since the reader uses a hash-table for symbol lookup it would seem to be a trivial thing to add.

marcoxa
Posts: 85
Joined: Thu Aug 14, 2008 6:31 pm

Re: Conflict between iterate and cl-containers

Post by marcoxa » Thu Dec 12, 2013 1:39 pm

Look at SHADOW and SHADOWING-IMPORT.
Marco Antoniotti

budden73
Posts: 8
Joined: Sat Jan 04, 2014 8:25 am

Re: Conflict between iterate and cl-containers

Post by budden73 » Sat Jan 04, 2014 8:30 am

Hi! I use patched version of iterate, http://sourceforge.net/projects/iteratekeywords/
It allows using keywords in head clauses.

So I write
(iter (:for x :in ...) (:collect ...))
instead of
(iter (iter:for x :in ...) (iter:collect ... ))
so no obfuscation and no conflicts.

marcoxa
Posts: 85
Joined: Thu Aug 14, 2008 6:31 pm

Re: Conflict between iterate and cl-containers

Post by marcoxa » Sun Jan 05, 2014 7:40 am

The real question is:

Are you sure you need ITERATE? I.e., are you sure you couldn't just use LOOP?

Cheers
--
MA
Marco Antoniotti

Post Reply