Shadowing Question

Discussion of Common Lisp
Post Reply
sabra.crolleton
Posts: 16
Joined: Sat Sep 13, 2008 6:46 pm

Shadowing Question

Post by sabra.crolleton » Mon Aug 30, 2010 8:35 am

If I use both hunchentoot and log5 in the application, I generate a name-conflict between the log-message functions in the two packages. If I understand shadowing-import correctly, if I call (shadowing-import-from :hunchentoot :log-message) then log5:log-message won't be visible. That would imply that log5 won't work correctly. Obviously I'm misunderstanding how this works. How do you get both packages to work in the same application?

ramarren
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland
Contact:

Re: Shadowing Question

Post by ramarren » Mon Aug 30, 2010 10:48 am

Symbols have qualified and unqualified syntax. Qualified syntax includes the package name and it always refers to the same symbol no matter the current package or its state, so 'log5:log-message' is always visible. Unless you modify the state of 'log5' package, but you should not modify library packages, always create your own package for your application. Usually you wouldn't use package modification functions either, it is best to define all properties of a package in DEFPACKAGE form.

Shadowing affects only the symbol resolution of unqualified symbol syntax in the affected package. Shadowing a symbol in your application package will not affect operation of any code read using any other packages. If for some reason you need to use in your application symbols with the same namestring from two different packages then use a fully qualified form for one or both of them.

sabra.crolleton
Posts: 16
Joined: Sat Sep 13, 2008 6:46 pm

Re: Shadowing Question

Post by sabra.crolleton » Mon Aug 30, 2010 11:11 am

Thank you. I think my first mistake was including log5 in the :use section of defpackage instead of just in the :depends-on of defsystem and calling the fully qualified name.

Post Reply