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 7755849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:40:04+00:00 2026-06-01T12:40:04+00:00

Consider I have large library package with sophisticated tree of private or package modules

  • 0

Consider I have large library package with sophisticated tree of private or package modules — let’s call it funnylib. It’s not desirable for enduser to touch internal modules directly (like funnylib.foo, funnylib.bar etc), so I want to provide external interface instead — like this:

funnylib.d:

public import funnylib.foo;
public import funnylib.bar;
public import funnylib.baz;

to be just imported like import funnylib by enduser. The problem is that D disallows having funnylib.d and funnylib/ at the same time.

Is there something like “default package module” in D, like there is __init__.py in Python? If no, what is right way to do design described above?

Update1: I thought about moving iternal modules to package like funnylib_private, so funnylib will import fine, but this will have cost of protection lowering (strongly undesirable), as funnylib will no longer access package protected symbols, and will result in unpleasant file layout.

  • 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-01T12:40:05+00:00Added an answer on June 1, 2026 at 12:40 pm

    You cannot have a module and a package with the same name. So, for instance, Phobos couldn’t have a std/algorithm.d and a std/algorithm/sorting.d. std/algorithm.d and std/algorithm would conflict. The typical thing to do is what ratchet freak describes and use a module named all which publicly imports all of the modules within that package. But if you want to hide the fact that you’re using sub-modules at all, then you could simply do something like

    funnylib.d
    _funnylib/foo.d
    _funnylib/bar.d
    _funnylib/baz.d
    

    and not document _funnylib anywhere, but that doesn’t work very well with ddoc, because it’s going to generate the documentation for each of the _funnylib modules, and the most that it’ll generate for funnylib.d is the module documentation, because it doesn’t have any symbols to document. The module system is not designed with the idea that you’re going to be hiding modules like you’re trying to do.

    Now, there is currently a proposal under discussion for making it possible to cleanly split up a module into a package when it gets too large (e.g. so that when you split up std.algorithm into std.algorithm.search, std.algorithm.sorting, etc. code which explicitly uses std.algorithm.countUntil won’t break even though it’s now std.algorithm.search.countUntil). And once that’s sorted out, you could use that, but the documentation would still be done for each sub-module, not for your uber-module. It’s really meant as a means of transitioning code, not trying to hide the fact that you’re splitting up your modules. It’s basically just the equivalent of using an all module but with some semantic sugar to avoid breaking code in the case where the package used to be a single module.

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

Sidebar

Related Questions

Let's consider we have QWidget that contains QTableWidget (only). So we want to resize
We have a SharePoint 2007 deployment which will have a substantially large document library.
I have a fairly large Drupal 6 site with different modules enabled for different
Consider I want to develop a large enterprise application. In my application I have
I have a large tree-like data structure of objects which behave mostly identical but
Consider the SlidingDrawer in Android. All samples I've seen have a large button as
Consider I have the following interface: public interface A { public void b(); }
Consider I have a shared function:- Public Shared Function CalculateAreaFromRadius(ByVal radius As Double) As
Consider I have an array of elements out of which I want to create
Consider I have two arrays: $friends = Array('foo', 'bar', 'alpha'); $attendees = Array('foo', 'bar');

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.