Skip to content

Document "toplevel" #58912

Open
Open
@moble

Description

@moble

The word "toplevel" is used in a few places in the documentation, but not actually defined or discussed in any depth at all. But then there is at least one situation where it has to be used in code, with no reason is given. Specifically, one would think that this code should work:

macro mymodule(name)
    modname = esc(name)
    return :(module $modname end)
end
@mymodule MyMod

And in fact, it used to up to Julia 1.4. But now, that macro mysteriously needs to

return Expr(:toplevel, :(module $modname end))

Why?! The output from the first one isn't hidden in a block or anything; it would appear to be at the level at which it was run — the top level, as far as I can see.

I've asked on discourse with no response, but anyway I think something about this should be somewhere in the docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsThis change adds or pertains to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions