caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Duplicate value specifications
@ 2017-02-23 15:11 Jeremy Yallop
  2017-02-23 16:44 ` Gabriel Scherer
  0 siblings, 1 reply; 2+ messages in thread
From: Jeremy Yallop @ 2017-02-23 15:11 UTC (permalink / raw)
  To: Caml List

Are duplicate value specifications a supported feature of signatures?
Will the following program, which is currently accepted, continue to
be accepted in future versions of OCaml?

  module type S = sig
    val x : int
    val x : bool
  end

This is an artificial example, of course, but duplication can
sometimes arise naturally through signature inclusion.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Duplicate value specifications
  2017-02-23 15:11 [Caml-list] Duplicate value specifications Jeremy Yallop
@ 2017-02-23 16:44 ` Gabriel Scherer
  0 siblings, 0 replies; 2+ messages in thread
From: Gabriel Scherer @ 2017-02-23 16:44 UTC (permalink / raw)
  To: Jeremy Yallop; +Cc: Caml List

Historically my understanding is that the signature language mimicks
the structure language in this respect, and that while shadowing of
type declarations is rejected for soundness, shadowing of value
definitions (as structure items) are accepted as they are a somewhat
common pattern.

We discussed this indirectly in PR#5878 (
https://caml.inria.fr/mantis/view.php?id=5878 ). My personal belief
about "ideal OCaml" is that repeated declarations and definitions of
the same identifier (either at the type or value level) should be
allowed as long as they are "unifiable" (have an upper bound in the
definedness order), and that the effect should be identical to a
single declaration of the unified result (the upper bound). In this
world, you example is rejected because the two definitions are
incompatible.

(This definedness-order idea allows repeating the same type definition
twice, or giving once an abstract declaration and then a concrete
definition, or specifying the variance separately from the rest of the
declaration, or using "val x : ..." as an annotation followed by a
"let x = ..." definitions.)

On Thu, Feb 23, 2017 at 10:11 AM, Jeremy Yallop <yallop@gmail.com> wrote:
> Are duplicate value specifications a supported feature of signatures?
> Will the following program, which is currently accepted, continue to
> be accepted in future versions of OCaml?
>
>   module type S = sig
>     val x : int
>     val x : bool
>   end
>
> This is an artificial example, of course, but duplication can
> sometimes arise naturally through signature inclusion.
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-23 16:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-23 15:11 [Caml-list] Duplicate value specifications Jeremy Yallop
2017-02-23 16:44 ` Gabriel Scherer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).