Skip to content

Replace (literal / variable) with operand in definition of option #412

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

Closed
wants to merge 1 commit into from

Conversation

catamorphism
Copy link
Collaborator

operand is now defined as literal / variable, so the definition of option can use operand instead of (literal / variable) (and should, for clarity.)

@eemeli
Copy link
Collaborator

eemeli commented Jul 5, 2023

While this makes sense from a DRY point of view, I left out this optimisation because I don't think "operand" is an appropriate term for the value of an option: #395 (comment).

@catamorphism
Copy link
Collaborator Author

catamorphism commented Jul 5, 2023

While this makes sense from a DRY point of view, I left out this optimisation because I don't think "operand" is an appropriate term for the value of an option: #395 (comment).

I see your point. Perhaps something like:

expression = "{" [s] ((atom [s annotation]) / annotation) [s] "}"

option = name [s] "=" [s] atom

atom = literal / variable

Or even, to keep the term "operand" around for clarity:

expression = "{" [s] ((operand [s annotation]) / annotation) [s] "}"

option = name [s] "=" [s] atom

operand = atom
atom = literal / variable

Why make the change? It's not crucial, but when working on #402, I found it awkward to express this text. I wanted to be able to say that when a variable appears in an operand context, the variable's name must already be in scope. But to be precise, the text has to say "when a variable appears as an operand or as the variable in an option", which is verbose. If option also referred to operand, it would be simpler. The same situation might arise elsewhere in the spec.

An alternative that helps with the exposition in #402 is to change the grammar to distinguish variable references from variable definitions. But even if we also made that change, I could imagine it being useful to write "in an atom" instead of "in an operand or in the literal or variable of an option.

(I prefer to avoid "value" since if value was a non-terminal in the grammar, that clashes with the concept of a semantic value (resolved value). A variable would be an example of a value in the grammar, but would not be a resolved value in the semantics, which I think is potentially confusing.)

@eemeli
Copy link
Collaborator

eemeli commented Jul 6, 2023

An alternative that helps with the exposition in #402 is to change the grammar to distinguish variable references from variable definitions. But even if we also made that change, I could imagine it being useful to write "in an atom" instead of "in an operand or in the literal or variable of an option.

As we discussed in #393 (comment) regarding the data model, I agree that the left-hand side of a declaration should be called something different than the places where we're using variable to look up its value.

At its simplest, it could be just

declaration = let s "$" name [s] "=" [s] expression

but including an intermediate construct like your proposed variable-definition would also work.

It would be easier to continue consideration of whether something like atom ought to be introduced after this change.

@stasm
Copy link
Collaborator

stasm commented Jul 11, 2023

Some (experimental) prior work:

@aphillips
Copy link
Member

close per discuss in wg call. may reopen in the future based on discussion of semantics for "value"

@aphillips aphillips closed this Aug 28, 2023
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.

4 participants