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

Implement var-args for macros #225

Open
grayswandyr opened this issue Dec 11, 2023 · 0 comments
Open

Implement var-args for macros #225

grayswandyr opened this issue Dec 11, 2023 · 0 comments

Comments

@grayswandyr
Copy link
Contributor

grayswandyr commented Dec 11, 2023

Macros allow to implement an unchanged macro as:

let unchanged[x] { (x) = (x)' }

But, in every event, this macro should be called for every unchanged relation (or part of, e.g. with <:), as in:

var sig S { var r1, r2 : set S }
...
pred ev[...] {
  ...
  unchanged[S]
  unchanged[r1]
  unchanged[x <: r2]
  ...
}

Can we implement a single call to unchanged? Almost, using meta... The following is possible:

let allUnchanged[X] { all x: X | x.value = (x.value)' }
pred ev[...] {
  ...
  allUnchanged[S$ + S$r1] // won't work with `x <: r2`
  unchanged[x <: r2]
  ...
}

The allUnchanged macro is nice but (1) it must be called with ugly meta-arguments (incl. fully-qualified meta-names like S$r1) and (2) it only works for fully-unchanged stuff (it won't work on x <: r2.

I am here proposing that we add comma-delimited var-args to macros as well as an args$ meta-sig, local to its enclosing macro, so that something like this could be written:

let allUnchanged[X] { all x : args$ | x = (x)' }
pred ev[...] {
  ...
  allUnchanged[S, r1, (x <: r2)]
  ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant