-
Notifications
You must be signed in to change notification settings - Fork 31
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
[CN] Streamline spec
syntax
#500
Comments
I think this would be unambiguously a good change! I wonder about requiring that Note related grumbling here: #467 |
One things that's nice about this is that if the Though, why not then drop the |
I love this idea. Following up on what @cp526 said, can we simply make function specifications on definitions and declarations the same? If we decide to batch up breaking changes, moving specs to precede the function name would help unify these two cases, e.g.
FWIW this is how Frama-C places annotations. |
We used to have function specifications precede their definition but moved away from it because it leads to less readable specifications: when specifications precede the definition, the syntax doesn’t reflect the binding structure, since the function arguments are in scope of the specification but are introduced only below it. |
I see what you mean, but in some sense, CN annotations are simply structured comments. There's a long history of doc generation based on structured comments that have forward references to the function they're documenting (doxygen, javadoc, etc.). Putting the spec after function decls is also a little weird w.r.t. scoping:
|
FWIW Frama-C orders specs before definitions: https://www.frama-c.com/html/acsl.htmlOn Aug 30, 2024, at 10:31 AM, Cole Schlesinger ***@***.***> wrote:
I see what you mean, but in some sense, CN annotations are simply structured comments. There's a long history of doc generation based on structured comments that have forward references to the function they're documenting (doxygen, javadoc, etc.).
Putting the spec after function decls is also a little weird w.r.t. scoping:
void my_decl();
// This is not in scope of this declaration.
void my_decl()
// This is... kind of?
;
// This is also not in scope, but it's common for comments to precede the thing they're commenting on.
void my_decl();
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
As far as I can see, unifying the syntax for CN specifications for function definitions and function prototypes is independent of where the specification is placed, no? |
Yes, we can unify the syntax without unifying the placement, so no need to make a decision on placement to move forward with the other bit. |
Current syntax for
spec
requires user to retype function name and argument types. It's flexible, but tedious. Here's a proposal for not doing that.Restriction on C syntax: should error (require specs to name arguments).
Restriction on C syntax: should error (zero or more than one declaration previously):
Should error (not a function):
Should work without repeating function name:
The text was updated successfully, but these errors were encountered: