Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filing a set of futures relating to module init order / main modules #5076

Merged
merged 1 commit into from
Dec 18, 2016

Conversation

bradcray
Copy link
Member

These tests threw me for a loop for awhile this evening (along the line
of "Why is my code not running?!?!"

The challenges relate to which modules are candidates for the main
module and which modules' init functions (top-level code) are run.
What we have today is rationalizable, but here I propose that some
warnings might help avoid confusion in cases like this.

I think what we have today is:

  • modules that are 'require'd or named on the command-line are candidates
    for main modules; if a module is not in this group, it is not
    a candidate for the main module and its main() will not be run.
  • among the modules that are candidates for main modules, if only one has
    main(), it is the main module
  • once the main module is determined, module initialization is determined
    by walking the tree of 'use's starting from the 'main' module
  • if a module is named on the command-line but is not reached via this
    tree, its initialization (top-level code) will not be run.

As I say in the .future, I think this is rationalizable, but it can be confusing
in some cases. To that end, I propose putting a warning when modules
fall into bullet 4's case to avoid surprises.

The challenges relate to which modules are candidates for the main
module and which modules' init functions (top-level code) are run?
What we have today is rationalizable, but here I propose that some
warnings might help avoid confusion in cases like this.  See the
.future for details.
@bradcray bradcray merged commit 5427d00 into chapel-lang:master Dec 18, 2016
@bradcray bradcray deleted the moduleInitConfusion branch December 18, 2016 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant