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

export @using and add docstring #709

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

hhaensel
Copy link
Member

@hhaensel hhaensel commented Mar 4, 2024

Loading of modules is currently done via Revise.includet()
This is slow as it doesn't allow for precompilation.

My proposal is to replace this procedure by using statements when possible.

To make that procedure easier I have written a handy @using macro that does the following.

Here's the doc string:

@using(package_path)

macro to simplify loading of modules that are not located in the LOAD_PATH

package_path can be

  • a path to a directory containing a module file of the same name
    e.g 'models/MyApp' to load 'models/MyApp/MyApp.jl'
  • a path to a module (without extension '.jl')
    e.g. 'models/MyApp' to load models/MyApp.jl'
  • a path to a package directory containing a 'src' directory and module file therein
    e.g. 'models/MyApp' to load 'models/MyApp/src/MyApp.jl'

Examples

@using models/MyApp

@using StippleDemos/Vue3/Calendars

or explicitly

@using StippleDemos/Vue3/Calendars/Calendars

Note, directories containing special characters like colon (':') or space (' ')
need to be escaped by double quotes.

@using "C:/Program Files/Julia/models/Calendars"

# or
@using "C:/Program Files"/Julia/models/Calendars

Caveat: Due to precompilation it is not possible to supply variables to the macro.
Calls need to supply explicit paths.

@essenciary essenciary merged commit 40c0f1b into GenieFramework:master Mar 5, 2024
8 of 11 checks passed
@essenciary
Copy link
Member

Pretty cool, thanks @hhaensel !

@PingoLee
Copy link

PingoLee commented Jul 8, 2024

Who using @using in MVC app?

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.

3 participants