Skip to content

Conversation

@dc-mak
Copy link
Collaborator

@dc-mak dc-mak commented Mar 7, 2025

To fix #311. Experimental.

dc-mak added 3 commits March 7, 2025 19:24
This commit is the first in a series to address rems-project#311, by allowing users
to name the (quantified) resource they want to focus on.

The precise syntax will probably change in response to user feedback,
but right now it is `take <sym> = <resource> as <sym'>;` where "as" is a
new keyword and "<sym'>" is a symbol. At this point, the latter part
is optional, to preserve backwards compatibility.

Only quantified predicates really _need_ names, but to forbid names on
regular resources grammatically seems overly restrictive, so we shall
see how that plays out.

A tentative plan for how names evolve is:

|--------------------------|-----------|
| Owned<struct s>(..) as H | H.<field> |
| Owned<ct[10]> as H       | H[<index> |
| focus H[<var>];          | H[<var>]  |
| focus H[<expr>] as H'    | H'        |
| partial consumption      | H         |
| unfold a user-def pred   | H.<names> |

Also need a way of naming the ensures of a function call.

I believe there is no need to consider generating names for predicate
folds because that will only happen on demand at an ensures or preceding
a function call.

Perhaps the "names" of the resources in the context actually need to be
terms, e.g. to deal smoothly with H[<expr>].
This commit adds support in the parser and Cabs to having a single magic
comment at the end of an call expression. It still needs to be
pretty-printed as well as translated into correct/useful Ail.
@dc-mak
Copy link
Collaborator Author

dc-mak commented Mar 8, 2025

Better to split into separate PRs:

Given that there are already usable symbols for this, will be easier to try a resourceof syntax than introduce and thread new a new kind of binder.

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

Successfully merging this pull request may close these issues.

[CN] Extract should (allow user to) be more specific

1 participant