Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8704659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:09:48+00:00 2026-06-13T03:09:48+00:00

Obviously, the externally visible API is published by exporting symbols. But… what if I

  • 0

Obviously, the externally visible API is published by exporting symbols. But… what if I have multiple packages (say A, B and C) and A’s exported symbols are not all meant to be part of the external API – some of them are needed for B and C? (similarly, B exports some symbols for A and C and some for the external API; C is the ‘toplevel’ package and all its exported symbols are part of the public API; I want to keep things modular and allow A to hide its innards from B and C, so I avoid ‘::’).

My solution right now is to re-export everything that is meant to be public from C and document that the public API consists only of C’s exported symbols and people should stay away from public symbols of A and B under pain of bugs and code broken in the future when internal interfaces change.

Is there a better way?

UPDATE: This is my implementation of my understanding of Xach’s answer:

First, let me complete my example. I want to export symbols symbol-a-1 and symbol-a-2 from package a, symbols symbol-b-1 and symbol-b-2 from package b and symbols api-symbol-1 and api-symbol-2 from package c. Only the symbols exported from c are part of the public API.

First, the definition for a:

(defpackage #:a
  (:use #:cl))

Note that there aren’t any exported symbols 🙂

A helper macro (uses Alexandria):

(defmacro privately-export (package-name &body symbols)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (defun ,(alexandria:format-symbol *package*
                                       "IMPORT-FROM-~a"
                                       (symbol-name package-name)) ()
       (list :import-from
             ,package-name
             ,@(mapcar (lambda (to-intern)
                         `',(intern (symbol-name to-intern) package-name))
                       symbols)))))

Use the macro to ‘export privately’ 🙂 :

(privately-export :a :symbol-a-1 :symbol-a-2)

Now the definition of b:

(defpackage #:b
  (:use #:cl)
  #.(import-from-a))

… b‘s ‘exports’:

(privately-export :b :symbol-b-1 :symbol-b-2)

… c‘s definition:

(defpackage #:c
  (:use #:cl)
  #.(import-from-a)
  #.(import-from-b)
  (:export :api-symbol-1 :api-symbol-2)

Problems with this approach:

  • a cannot use symbols from b (without importing symbols from b from a after both have been defined);
  • the syntax package:symbol is basically not usable for symbols exported ‘privately’ (it’s either just symbol or package::symbol).
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:09:49+00:00Added an answer on June 13, 2026 at 3:09 am

    If A and B are primarily for the implementation of C, you can have C’s defpackage form drive things with selective use of :import-from, since you can import things that aren’t external. Then you can selectively re-export from there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Obviously I'd like to not have to install an Oracle client (other than simply
Obviously, sets do not have any kind of ordering, so I cannot expect any
I have multiple (read 10s) MySQL slaves running in a LAN. Obviously, I cannot
Obviously best-case is O(n), but apparently the worst-case is O(n 2 ), which I
Obviously it's early days, I do not know whether this is information that is
Although obviously not all scenarios can be covered by a single design, is it
So obviously I am doing something wrong, but I just cannot seem to get
Let's say I have the following code, which I CANNOT modify var namespace =
Here is the function I have now that obviously doesn't work. The reason it
Say I have a string in Python 3.2 like this: '\n' When I print()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.