SATySFi
SATySFi copied to clipboard
Rename 'open' to 'include', then deprecate 'open'
Currently, SATySFi has 3 forms of open
:
-
open M
: globalopen
-
open M in expr
: localopen
-
M.(expr)
: lightweight localopen
Only (1) is related to this PR. The other 2 forms are irrelevant.
SATySFi's global open
(hereafter, just call open
) is similar to OCaml's include
, not OCaml's open
, because it re-exports the definitions in a module.
open
/ include
in modules, wrap-up:
Standard ML | OCaml | SATySFi (current) | SATySFi (ideal) | |
---|---|---|---|---|
re-export | open |
include |
open |
include |
not re-export | open |
open |
In my experience with Standard ML, the absence of OCaml-style open
is to some extent painful, even though Standard ML has local ... in ... end
, which makes Standard ML-style open
a bit more local.
Moreover, we cannot omit module prefixes in signatures (in a natural way) if OCaml-style open
is not supported. Compare these (contrived) OCaml programs:
sig
type s = int * Mod.t
val v : Mod.t list -> Mod.u option
val f : Mod.t -> s
end
sig
open Mod
type s = int * t
val v : t list -> u option
val f : t -> s
end
On the other hand, OCaml-style include
is also useful, especially when combined with functors and to extend modules with additional definitions.
So I believe both open
and include
should be implemented in SATySFi. Since SATySFi has many similarities with OCaml, it would be appropriate to use the same keywords as OCaml. As a first step, this PR adds a keyword include
as an alias to open
. Furthermore, if a program contains (global) open
, SATySFi warns about it, leading the programmer to refrain from using open
.
Plan
I propose the following plan.
- Phase 1: Introduce
include
, and warn the use ofopen
. (What this PR does.) - Phase 2: Remove
open
. - Phase 3: Introduce OCaml-style
open
.