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

Main entrypoint take 3 - revenge of the macro #51435

Merged
merged 1 commit into from
Oct 8, 2023
Merged

Main entrypoint take 3 - revenge of the macro #51435

merged 1 commit into from
Oct 8, 2023

Commits on Oct 8, 2023

  1. Main entrypoint take 3 - revenge of the macro

    As they say, if at first you don't succeed, try again, then
    try again, add an extra layer of indirection and take a little
    bit of spice from every other idea and you've got yourself a wedding
    cake. Or something like that, I don't know - at times it felt like
    this cake was getting a bit burnt.
    
    Where was I?
    
    Ah yes.
    
    This is the third edition of the main saga (#50974, #51417). In
    this version, the spelling that we'd expect for the main use case is:
    ```
    function (@main)(ARGS)
        println("Hello World")
    end
    ```
    
    This syntax was originally proposed by `@vtjnash`. However, the semantics
    here are slightly different. `@main` simply expands to `main`, so the above
    is equivalent to:
    ```
    function main(ARGS)
        println("Hello World")
    end
    @main
    ```
    
    So `@main` is simply a marker that the `main` binding has special behavior.
    This way, all the niceceties of import/export, etc. can still be used
    as in the original `Main.main` proposal, but there is an explicit
    opt-in and feature detect macro to avoid executing this when people
    do not expect.
    
    Additionally, there is a smooth upgrade path if we decide to automatically
    enable `Main.main` in Julia 2.0.
    Keno committed Oct 8, 2023
    Configuration menu
    Copy the full SHA
    7847dcc View commit details
    Browse the repository at this point in the history