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

Remove obsolete locality #1049

Merged
merged 1 commit into from Nov 30, 2017

Conversation

maximedenes
Copy link
Member

We remove deprecated syntax "Coercion Local" and such, and seize the
opportunity to refactor some code around vernac_expr.

This is a preliminary step for the work on attributes.

We also fix a related classification issue in the STM.

@silene
Copy link
Contributor

silene commented Sep 13, 2017

The existence of both Discharge:discharge and Discharge:locality confuses me to no end. I am even surprised you never had to disambiguate between the two, for example in vernac/lemmas.ml.

@maximedenes
Copy link
Member Author

Well, they really mean the same thing. So is that so much of a problem? And of course, the point is to make the discharge type disappear at some point.

@SkySkimmer
Copy link
Contributor

Ocaml is pretty smart about disambiguating constructors. Enable warnings 41 and 42 in the configure.ml to see how much it happens in the coq code.

@maximedenes
Copy link
Member Author

I'm fine with changing it btw, if you suggest a name :)

@maximedenes
Copy link
Member Author

In fact maybe I have a candidate. We could rename Discharge:locality into SectionLocal because it will then reflect the three values I plan to allow for this attribute.

@silene
Copy link
Contributor

silene commented Sep 13, 2017

We could rename Discharge:locality into SectionLocal

What would Local:locality mean then? ModuleLocal? (Is that a thing?)

@maximedenes
Copy link
Member Author

What would Local:locality mean then? ModuleLocal? (Is that a thing?)

Yes. (I guess)

@maximedenes
Copy link
Member Author

maximedenes commented Sep 13, 2017

Note that it is already what it means. AFAIK

@silene
Copy link
Contributor

silene commented Sep 13, 2017

Note that it is already what it means.

It is not always clear to me when Local means module or file locality. Anyway, yes, please change locality to reflect these subtle details; that would be quite an improvement over the current code.

@maximedenes
Copy link
Member Author

Oh my god! I realize only now a huge flaw of this PR. The syntax:

Coercion Local zar := fun n : nat => n.

is still valid (but with a different meaning), since Local is not a keyword.

@maximedenes
Copy link
Member Author

It is not always clear to me when Local means module or file locality. Anyway, yes, please change locality to reflect these subtle details; that would be quite an improvement over the current code.

The Local keyword (which is not a keyword) can mean module-local or section-local, but IIUC, Local:locality means module-local. You're right, I'll update the code to better reflect it.

Any objection to making Local and Global true keywords? Otherwise I don't see how to guarantee that this removal will not do crazy things.

@SkySkimmer
Copy link
Contributor

Otherwise I don't see how to guarantee that this removal will not do crazy things.

Leave the grammar entry in but parse to an error?

@silene
Copy link
Contributor

silene commented Sep 13, 2017

Any objection to making Local and Global true keywords?

No objection on my side, and Coercion too.

But it seems that there has never been any warning Deprecated syntax: use "Local" as a prefix regarding Coercion Local. This is a serious flaw, which should be dealt with, as soon as in 8.7.

@maximedenes
Copy link
Member Author

Leave the grammar entry in but parse to an error?

Yeah, but it's many grammar entries, and the point of this PR was to remove them :)

@maximedenes
Copy link
Member Author

But it seems that there has never been any warning Deprecated syntax: use "Local" as a prefix regarding Coercion Local. This is a serious flaw, which should be dealt with, as soon as in 8.7.

Oh! I didn't know. I'll fix it, and hopefully try to make the beautifier do this translation for 8.7.

Copy link
Member

@herbelin herbelin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very good.

The solution adopted for Let does not look bad: like Coercion, Class, etc., it adds a flavor to Definition, namely here the Discharge flavor.

About Coercion Local, maybe an error for some while. Otherwise Definition Local := 0 is accepted, so why not Coercion Local?

About clarifying when Local/Global refers to a section or module scope, something remains to be done, certainly. Maybe elaborating about the names Private, Extern, ... @aspiwack and @ppedrot also had ideas about that.

(edited for typos)

@@ -1145,33 +1132,33 @@ GEXTEND Gram
| IDENT "Bind"; IDENT "Scope"; sc = IDENT; "with";
refl = LIST1 class_rawexpr -> VernacBindScope (sc,refl)

| IDENT "Infix"; local = obsolete_locality;
| IDENT "Infix";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To satisfy at the nitpicking tradition, I would delete the newline here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will fix, thanks!

@@ -546,7 +546,7 @@ GEXTEND Gram
d = G_vernac.def_body ->
let s = coerce_reference_to_id qid in
Vernacexpr.VernacDefinition
((Some Decl_kinds.Global,Decl_kinds.CanonicalStructure),
((NoDischarge,Decl_kinds.CanonicalStructure),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a change of semantics of Local Canonical? (By the way - heavily insisting 😄 -, what are the motivations and mid-term plans of SSReflect developers w.r.t. this redundancy?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I wasn't too sure about this one. Do you mean that the current default locality for definitions depend on their kind? I'll double check.

match discharge with
| Decl_kinds.NoDischarge -> GuaranteesOpacity
| Decl_kinds.Discharge -> Doesn'tGuaranteeOpacity
in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fix compared to previous version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, see commit message.

| None, NoDischarge -> Global
| None, Discharge -> Discharge
| Some true, Discharge -> CErrors.user_err Pp.(str "Local not allowed in this case")
| Some false, Discharge -> CErrors.user_err Pp.(str "Global not allowed in this case")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄

@herbelin
Copy link
Member

@silene:

> Coercion Local S:nat>->nat.
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning: Deprecated syntax: use "Local" as a prefix.
[deprecated-local-syntax,deprecated]

@maximedenes
Copy link
Member Author

Is it also triggered when the body is provided?

@herbelin
Copy link
Member

Is it also triggered when the body is provided?

Ah, ok, now I connect to the gitter quiproquo.

@maximedenes
Copy link
Member Author

It is not always clear to me when Local means module or file locality.

Oh, I had read your question incorrectly. I have no idea about the distinction of module locality vs file locality. @ppedrot?

Copy link
Member

@gares gares left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've only looked at the classifier fix

@maximedenes maximedenes added the needs: feedback Feeback from users and testers would be welcome. label Oct 9, 2017
@maximedenes
Copy link
Member Author

Oh, I had read your question incorrectly. I have no idea about the distinction of module locality vs file locality. @ppedrot?

@ppedrot?

@ppedrot
Copy link
Member

ppedrot commented Oct 9, 2017

@maximedenes What? The question is not even well-defined, there is not even such thing as a module or section locality, locality is a property of libobjects and they have idiosyncratic implementations that cannot be unified.

@ejgallego
Copy link
Member

idiosyncratic implementations that cannot be unified.

Not even in part? What could/would be some good candidates to move to a unified direct-control implementation?

@maximedenes maximedenes removed the needs: feedback Feeback from users and testers would be welcome. label Oct 11, 2017
@Zimmi48 Zimmi48 added the kind: cleanup Code removal, deprecation, refactorings, etc. label Oct 11, 2017
@maximedenes maximedenes added the needs: progress Work in progress: awaiting action from the author. label Oct 19, 2017
@maximedenes maximedenes added this to the 8.8 milestone Oct 30, 2017
maximedenes added a commit to maximedenes/fiat-crypto that referenced this pull request Nov 20, 2017
This is preparing the landing of coq/coq#1049.

For now, I'm duplicating this patch which was already done upstream in
CoqPrime, but please consider removing this ad-hoc copy (see discussion
on PR mit-plv#269).
andres-erbsen pushed a commit to mit-plv/fiat-crypto that referenced this pull request Nov 20, 2017
This is preparing the landing of coq/coq#1049.

For now, I'm duplicating this patch which was already done upstream in
CoqPrime, but please consider removing this ad-hoc copy (see discussion
on PR #269).
@maximedenes maximedenes force-pushed the remove-obsolete-locality branch 2 times, most recently from 60595d7 to 9bbb2f8 Compare November 21, 2017 22:16
@maximedenes maximedenes removed the needs: progress Work in progress: awaiting action from the author. label Nov 22, 2017
@maximedenes
Copy link
Member Author

@Zimmi48
Copy link
Member

Zimmi48 commented Nov 22, 2017

So have you chosen a solution to avoid the issue with Coercion Local and such. Have you made Local into a keyword?

@maximedenes
Copy link
Member Author

So have you chosen a solution to avoid the issue with Coercion Local and such. Have you made Local into a keyword?

No, I did not. Since this syntax was deprecated really a long time ago, I think it is ok. I should add an entry in CHANGES, to help porting, though.

@maximedenes maximedenes force-pushed the remove-obsolete-locality branch 2 times, most recently from 33a1b80 to dd65bb5 Compare November 23, 2017 16:34
@maximedenes maximedenes added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Nov 27, 2017
@maximedenes
Copy link
Member Author

We remove deprecated syntax "Coercion Local" and such, and seize the
opportunity to refactor some code around vernac_expr.

We also do a small fix on the STM classification, which didn't know about
Let Fixpoint and Let CoFixpoint.

This is a preliminary step for the work on attributes.
@maximedenes
Copy link
Member Author

@maximedenes maximedenes merged commit ae5944b into coq:master Nov 30, 2017
maximedenes added a commit that referenced this pull request Nov 30, 2017
@maximedenes maximedenes deleted the remove-obsolete-locality branch November 30, 2017 15:23
@Zimmi48 Zimmi48 removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Nov 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: cleanup Code removal, deprecation, refactorings, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants