Zulip Chat Archive

Stream: lean4

Topic: Enum Macro


Joseph O (May 28 2022 at 17:36):

Why can I not do this?

macro_rules
  | `(enum $id:ident { $[$ids:ident ,]* }) =>
    `(inductive $id where $[| $ids:ident]*)

error:

unexpected syntax
  inductive $id where$[
    | $ids:ident]*

expected command

Marcus Rossel (May 28 2022 at 17:42):

Did you define the enum-syntax before?

Joseph O (May 28 2022 at 17:43):

Marcus Rossel said:

Did you define the enum-syntax before?

Oh wait i think i forgot to change it

Joseph O (May 28 2022 at 17:44):

It works now

Notification Bot (May 28 2022 at 17:44):

Joseph O has marked this topic as resolved.

Notification Bot (May 28 2022 at 17:55):

Joseph O has marked this topic as unresolved.

Joseph O (May 28 2022 at 17:55):

Any way I can make this possible?

syntax "enum" ident "{" (ident ",")* ident "}" ";": command

macro_rules
  | `(enum $name:ident { $[$ids:ident ,]* $id:ident };) =>
    `(inductive $name where $[| $ids:ident]* | $id:ident)

Joseph O (May 28 2022 at 17:56):

Even better, make the last comma optional


Last updated: Dec 20 2023 at 11:08 UTC