@@ -72,6 +72,26 @@ def visibility :=
7272 withAntiquot (mkAntiquot "visibility" decl_name% (isPseudoKind := true )) <|
7373 «private » <|> «public »
7474def «protected » := leading_parser "protected "
75+ /--
76+ (module system) The `meta` modifier can be applied to a `def` in order to make it available for
77+ compile-time execution, e.g. as part of a macro or tactic. Specifically, attributes such as
78+ `@[macro]` require the annotated declaration to be `meta`, and recursively a `meta` definition may
79+ only refer to other `meta` definitions unless the reference is irrelevant for compilation purposes.
80+ However, imported definitions not originally marked `meta`, such as most parts of the standard
81+ library, can be retroactively be marked so during importing to allow their use in `meta`
82+ definitions. If the metaprogramming use is local to the current module, such as through
83+ `local macro`, this can be done by `meta import`; if the metaprogram is available to other modules
84+ as well, `public meta import` is required.
85+
86+ Conversely, `meta def` makes the definition unavailable for run-time use, e.g. as part of a
87+ `lean_exe` executable generated by Lake. Thus `def`s that are not marked `meta` (nor
88+ `noncomputable`) may not refer to `meta def`s either in compilation-relevant ways. There is no way
89+ to remove the `meta` modifier retroactively. For any potential mixed use of a definition, it should
90+ be defined without `meta` and then imported with the correct modifier as needed. In particular,
91+ the same module can be `import`ed and `meta import`ed at once in order to make such regular `def`s
92+ available in both `meta` and non-`meta` `def`s.
93+ -/
94+ @[builtin_doc]
7595def «meta » := leading_parser "meta "
7696def «noncomputable » := leading_parser "noncomputable "
7797def «unsafe » := leading_parser "unsafe "
@@ -92,7 +112,7 @@ All modifiers are optional, and have to come in the listed order.
92112`nestedDeclModifiers` is the same as `declModifiers`, but attributes are printed
93113on the same line as the declaration. It is used for declarations nested inside other syntax,
94114such as inductive constructors, structure projections, and `let rec` / `where` definitions. -/
95- @[builtin_doc] def declModifiers (inline : Bool) := leading_parser
115+ def declModifiers (inline : Bool) := leading_parser
96116 optional docComment >>
97117 optional (Term.«attributes » >> if inline then skip else ppDedent ppLine) >>
98118 optional visibility >>
0 commit comments