-
Notifications
You must be signed in to change notification settings - Fork 16
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
pps: support for spec comments preceding specified items #143
Comments
To give a bit of insight, actually the result of the preprocessor is not a valid OCaml file: [@@gospel {| a = make n x
requires n > 0
ensures forall i. a(i) = x |}]
val make : int -> 'a -> 'a t You can experiment with it using the We tried to make the preprocessor as simple as possible (because attachment is a tricky thing to do properly), but I agree it would be nice to support more layout cases. In the meantime, I've clarified that we only support comments after in #149. |
Thanks! |
@n-osborne and I just had a look at this and the reason why it's not implemented now is it would mess with the locations (which we think is not worth doing), since you would want to preprocess (*@ a = make n x
requires n > 0
ensures forall i. a(i) = x *)
val make : int -> 'a -> 'a t into val make : int -> 'a -> 'a t
[@@gospel {| a = make n x
requires n > 0
ensures forall i. a(i) = x |}] We could add location annotations to fix this though. |
I note that in Cameleer, it is really painful to have to write the specification of a function after the whole function (whose code can be long). In the end I think we will want to write the spec in front of the code in an |
It makes sense indeed. I'm not so sure about how Cameleer works about this (/cc @mariojppereira) but I suspect it translates them into attributes in the same location which might explain why you have to write them afterwards. |
This is exactly the case. @fpottier , are you suggesting something like the following?
This is still possible, as I can attach the Gospel attribute (generated by the preprocessor) to the |
I think using |
If we forget about
I can make an effort inside the preprocessor to move the attribute to the next |
Yes! Allowing the spec to appear in front of the code. |
We should document this in the short term, before we fix this. |
As this is now documented, I remove it from the milestone. |
The following .mli file gives rise to
Error: OCaml syntax error
:The error message seems incorrect: this is a valid OCaml file.
More generally, OCaml allows documentation comments to appear either before or after the object that they document. It would be good if the same was true of Gospel comments. Thus, I would expect the following to be accepted:
Or, if we insist that Gospel comments must come after the object that they document, then perhaps this should be documented.
The text was updated successfully, but these errors were encountered: