Zulip Chat Archive
Stream: lean4
Topic: How are attributes defined?
Yuri de Wit (Dec 16 2021 at 22:55):
Where do attributes such as @[extern ...] or @[inline] comes from in Lean4? Are these basically built-in or part of a general strategy to allow custom metadata added to syntax elements? This question came up wondering whether they could be used to build a library for parsing command line arguments.
Mario Carneiro (Dec 16 2021 at 22:56):
They are syntactically elements of the attr
syntax category, although many of them fall into a simple subcategory of the form ident : attr
Arthur Paulino (Dec 16 2021 at 23:00):
@Yuri de Wit maybe this can help you. extern
is a parametric attribute (rather than a simple tag attribute that takes no parameters)
Arthur Paulino (Dec 16 2021 at 23:00):
More: https://github.com/leanprover/lean4/tree/master/src/Lean/Compiler
Yuri de Wit (Dec 16 2021 at 23:11):
Thanks, @Arthur Paulino and @Mario Carneiro ! I found the definitions for TagAttribute and ParametricAttribute and now have something to chase from here. I have never defined custom syntax/macros in Lean (in fact know practically nothing about Lean) and may come back with more questions.
Last updated: Dec 20 2023 at 11:08 UTC