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

Style of "equivalent to" #1119

Closed
tkoeppe opened this issue Nov 24, 2016 · 17 comments
Closed

Style of "equivalent to" #1119

tkoeppe opened this issue Nov 24, 2016 · 17 comments
Assignees

Comments

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 24, 2016

In the library, we have a term of art "equivalent to" to specify effects. What we don't have is a consistent way of formatting it. Currently observed forms:

  1. Equivalent to: [codeblock]
  2. Equivalent to: statement;
  3. Equivalent to: expression;
  4. Equivalent to expression.
  5. Equivalent to statement; where foo is bar.

I think we should definitely have the colon after "to", and we should probably have both a codeblock and an inline form.

@jwakely
Copy link
Member

jwakely commented Nov 24, 2016

This was discussed earlier this year. I think we agreed that the third form is wrong (we shouldn't use a semi-colon after an expression, only after a statement) but that we do want all three of codeblock/statement/expression.

@jensmaurer
Copy link
Member

It seems we're using "Equivalent to expression." quite a lot, and only use a colon if a statement or codeblock follows.

@tkoeppe
Copy link
Contributor Author

tkoeppe commented Nov 24, 2016

Maybe we can settle on these forms:

Codeblock

-?- Effects: Equivalent to:

statement;

where we may optionally explain things used in the block.

Inline statement

-?- Effects: Equivalent to: statement;

Inline expression

-?- Effects: Equivalent to expression.

-?- Effects: Equivalent to f(n), where n is a value.

@jensmaurer
Copy link
Member

Sounds minimally-invasive vs. the status quo.

@jwakely
Copy link
Member

jwakely commented Nov 24, 2016

I think that's what we agreed to use previously, yes.

See also #694

@jensmaurer
Copy link
Member

@tkoeppe: Given Richard's explanation in #694, is there still some open issue? Note that the third of your forms above is a statement-expression, i.e. a valid statement.

@tkoeppe
Copy link
Contributor Author

tkoeppe commented Nov 24, 2016

OK, I think the detail that was missing from #694 is how to deal with continuing sentences, e.g. when something needs a retrospective definition. My concrete proposal here is to place a comma after an inline statement and never use an inline expression.

@jensmaurer
Copy link
Member

Do you have specific examples?

@tkoeppe
Copy link
Contributor Author

tkoeppe commented Nov 24, 2016

@jensmaurer: I realise that's a valid statement, but the idea is to partially specialize on such patterns and prefer "inline expression." when possible.

@tkoeppe
Copy link
Contributor Author

tkoeppe commented Nov 24, 2016

@jensmaurer: E.g. 20.7.2.4/1. I would add a comma there. 20.7.4/10 is particularly weird. Also 20.14.9/1.

@tkoeppe
Copy link
Contributor Author

tkoeppe commented Nov 24, 2016

Some "equivalent to" statements are also just poorly constructed. E.g. 21.3.1.6.2, compare p6 vs p17. I think the latter ("Equivalent to f().") should be preferred over the former ("Equivalent to: return f();"). We should add an appropriate rule.

@tkoeppe
Copy link
Contributor Author

tkoeppe commented Nov 24, 2016

@jensmaurer: Please leave this bug open until we have at least updated the style wiki.

@jensmaurer
Copy link
Member

jensmaurer commented Nov 24, 2016

"Equivalent to: return expression;" vs. "Equivalent to expression." We usually do "return expression" if expression has a type other than void, but it seems to me the simpler expression might be better. (47 obvious occurrences of the former.)

@zygoloid
Copy link
Member

If I recall correctly, we chose to use "Equivalent to: return expression;" in cases where a return value is produced, to make the connection between the expression and the value clearer.

See https://github.com/cplusplus/draft/wiki/Specification-Style-Guidelines#writing-effects-in-a-function-description for the existing description of the rules here.

@jensmaurer
Copy link
Member

@tkoeppe: That covers it, right?

@tkoeppe
Copy link
Contributor Author

tkoeppe commented Nov 25, 2016

@jensmaurer: The wiki is still missing information on how to continue with trailing definitions after the code, and maybe it should include a disambiguation rule for "equivalent to function-call" that I mentioned above.

@jensmaurer
Copy link
Member

I've updated the wiki.

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

4 participants