Skip to content

Remove reference name type.#7797

Merged
gares merged 2 commits intorocq-prover:masterfrom
maximedenes:rm-reference
Jun 19, 2018
Merged

Remove reference name type.#7797
gares merged 2 commits intorocq-prover:masterfrom
maximedenes:rm-reference

Conversation

@maximedenes
Copy link
Copy Markdown
Member

@maximedenes maximedenes commented Jun 13, 2018

reference was defined as Ident or Qualid, but the qualid type already
permits empty paths. So we had effectively two representations for
unqualified names, that were not seen as equal by eq_reference.

We remove the reference type and replace its uses by qualid.

This is still work in progress. We need to:

  • clean up a few changes we made before introducing qualid_is_ident
  • port plugins tracked in CI
  • add documentation in dev/doc/changes.md

@maximedenes maximedenes added the kind: cleanup Code removal, deprecation, refactorings, etc. label Jun 13, 2018
@maximedenes maximedenes added needs: progress Work in progress: awaiting action from the author. needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. labels Jun 13, 2018
@maximedenes maximedenes removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Jun 13, 2018

type qualid
type qualid_r
type qualid = qualid_r CAst.t
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we now expose this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We don't expose more, qualid_r is the old qualid and the new qualid was used in ad-hoc ways in many places.

Copy link
Copy Markdown
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.

At some time, the parser was building Qualid only with non-empty path (and probably it is still the case, at least in g_prim.ml4), so in practice, even if not enforced by the OCaml syntax, I would suspect that the invariant was satisfied and that no collision even happened.

On the other side, if I remember correctly, the only real interest in differentiating between Ident in Qualid was for Constrintern (intern_applied_reference, find_pattern_variable, ...). The test qualid_is_ident is as good with this respect.

If I understand correctly, you are keeping the difference between the concept reference (in the sense of ast-level version of GlobRef.t/variable) and the technical incarnation of this concept (an uninterpreted list of identifiers). Seems good.

So, altogether, I find that this PR makes sense (with the usual reserve of the opinion of plugin developers, but that's routine!).

Copy link
Copy Markdown
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.

Correct wrt ssr & ide.

If possible I'd made qualid a module and have Qualid.is_ident and Qualid.basename for example. But I was born with C, so I'm also fine with qualid_ ;-)

reference was defined as Ident or Qualid, but the qualid type already
permits empty paths. So we had effectively two representations for
unqualified names, that were not seen as equal by eq_reference.

We remove the reference type and replace its uses by qualid.
@maximedenes
Copy link
Copy Markdown
Member Author

@silene you're the owner of Libnames. Do you approve this PR?

@maximedenes
Copy link
Copy Markdown
Member Author

In fact, @gares is the secondary owner and already approved it. So the only remaining step is to provide overlays for all plugins.

@gares
Copy link
Copy Markdown
Member

gares commented Jun 18, 2018

I've only checked ssr and ide as my review says. Which other files do you want me to check?

@maximedenes
Copy link
Copy Markdown
Member Author

maximedenes commented Jun 18, 2018

I think the idea is that the owner of Libnames should approve the principle of the change. All the rest is just propagation.

@maximedenes
Copy link
Copy Markdown
Member Author

@ppedrot In Ltac2, I read:

(** Beware, at the raw level, [Qualid [id]] has not the same meaning as
    [Ident id]. The first is an unqualified global reference, the second is
    the dynamic reference to id. *)

which seems completely contradictory with the whole point of this PR. Can you explain a bit more?

@ppedrot
Copy link
Copy Markdown
Member

ppedrot commented Jun 18, 2018

@maximedenes That's just Ltac2 wrongly exploiting the difference between both representations. I need to fix that separately.

@maximedenes
Copy link
Copy Markdown
Member Author

That's just Ltac2 wrongly exploiting the difference between both representations. I need to fix that separately.

Ok, so I will submit a first blind patch that makes it compile, and will let you fix the semantics.

@ejgallego
Copy link
Copy Markdown
Contributor

Can't you provide a compatibility layer for plugins?

@maximedenes
Copy link
Copy Markdown
Member Author

Can't you provide a compatibility layer for plugins?

For now, I prefer to see errors on plugins that I plan to port myself, because there is already an ocean of deprecation warnings produced by plugins we track on CI.

But once that is done, I would be happy to implement a layer. Do you have a suggestion on how to do that?

@ejgallego
Copy link
Copy Markdown
Contributor

You can maybe make reference = qualid and then deprecate it. That won't be 100% but at least should give some warning? Dunno if that's worth it.

@ejgallego
Copy link
Copy Markdown
Contributor

I am also not sure I am a fan of the new naming, as qualid now also stands for unqualified ids. This is confusing IMHO.

@maximedenes
Copy link
Copy Markdown
Member Author

I am also not sure I am a fan of the new naming, as qualid now also stands for unqualified ids. This is confusing IMHO.

I think it is pretty standard that qualified identifiers allow empty prefixes, isn't it?

@ejgallego
Copy link
Copy Markdown
Contributor

I think it is pretty standard that qualified identifiers allow empty prefixes, isn't it?

Not in Coq I think.

@ppedrot
Copy link
Copy Markdown
Member

ppedrot commented Jun 18, 2018

@maximedenes Ltac2 made not to observe this difference.

@maximedenes
Copy link
Copy Markdown
Member Author

Ok, I ported all plugins. A side remark: having more uniform build systems for all those plugins wouldn't hurt.

I hope the naming issue is not blocking, as far as I'm concerned, this PR is ready modulo CI.

@maximedenes maximedenes removed the needs: progress Work in progress: awaiting action from the author. label Jun 18, 2018
@gares
Copy link
Copy Markdown
Member

gares commented Jun 19, 2018

Not in Coq I think.

Can you give an example where the syntax imposes qualification. I don't think it is the case.

@gares gares self-assigned this Jun 19, 2018
@Zimmi48
Copy link
Copy Markdown
Member

Zimmi48 commented Jun 19, 2018

I don't think it is the case.

Indeed, in the refman the notion of qualid is a superset for the notion of ident: https://coq.inria.fr/refman/language/gallina-specification-language.html#grammar-token-qualid

@ejgallego
Copy link
Copy Markdown
Contributor

I don't think it is the case.

Oh indeed you are right, shortest_qualid_of_foo will return an empty prefix. Sorry for the noise.

@gares gares added this to the 8.9+beta1 milestone Jun 19, 2018
@gares
Copy link
Copy Markdown
Member

gares commented Jun 19, 2018

@maximedenes can you ping the upstreams you made an overlay, I've to leave the lab now

@gares gares merged commit 133ac4f into rocq-prover:master Jun 19, 2018
gares added a commit that referenced this pull request Jun 19, 2018
@maximedenes
Copy link
Copy Markdown
Member Author

can you ping the upstreams you made an overlay, I've to leave the lab now

Sure, thanks for merging! Maybe I don't need to ping you, though ;)

@maximedenes maximedenes deleted the rm-reference branch October 1, 2018 07:09
@herbelin
Copy link
Copy Markdown
Member

herbelin commented Oct 10, 2018

Hi, I noted a regression introduced by this PR. At the time of printing, the information of whether we have a variable or a global reference seems to be lost. This is visible for instance by the loss of color when printing a constant or inductive or constructor.

Example:

Check nat.
(* formerly: nat is displayed in light green in coqtop and navy in coqide *)
(* now: no color *)

I don't know what would be the easier to fix it. At parsing time, we are not able to make the difference, but starting with the translation constr_expr -> glob_constr we should be able to tell the difference. So, there is here an asymmetry between parsing and printing which is delicate to deal with.

@maximedenes
Copy link
Copy Markdown
Member Author

Hi, I'd like to understand better. How was the distinction between variables and global references done previously?

@herbelin
Copy link
Copy Markdown
Member

I think it was Ident id vs Qualid id in Ppconstr.pr_reference.

@herbelin
Copy link
Copy Markdown
Member

@maximedenes: Maybe a cool way to fix the problem while at the same time making constr_expr more expressive is to enrich the cAst.t record. I don't know what e.g. @ejgallego has in mind, but maybe trying:

type 'a CAst.t = {
  v   : 'a;
  loc : Loc.t option;
  alt : 'a option
}

and in the case of reference, there could be a alt node carrying the full qualified path. (Then, we would have a choice to make for section variables, whether to qualify them or not.)

An alternative fix would be to add a field CVar to constr_expr which would make constr_expr a bit closer to glob_constr.

What do you think?

@ejgallego
Copy link
Copy Markdown
Contributor

and in the case of reference, there could be a alt node carrying the full qualified path. (Then, we would have a choice to make for section variables, whether to qualify them or not.)

And what would that field mean in all other constructors of the AST?

@herbelin
Copy link
Copy Markdown
Member

And what would that field mean in all other constructors of the AST?

It is an optional field, to give a possible alternative rendering (to be then propogated to Pp.t or to whatever outputting format). (I'm not saying that this is the solution, just trying to find one.)

ybertot pushed a commit to ybertot/coq that referenced this pull request Feb 20, 2019
ybertot added a commit to ybertot/coq that referenced this pull request Feb 20, 2019
maximedenes added a commit to maximedenes/coq that referenced this pull request Apr 25, 2019
maximedenes added a commit to maximedenes/coq that referenced this pull request May 6, 2019
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.

7 participants