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

allow uppercase filenames #3366

Closed
vicuna opened this issue May 31, 2002 · 2 comments
Closed

allow uppercase filenames #3366

vicuna opened this issue May 31, 2002 · 2 comments

Comments

@vicuna
Copy link

vicuna commented May 31, 2002

Original bug ID: 1177
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)

Bug description

Hello,

For aesthetic reasons (and being german) I prefer to capitalise
filenames, i.e., Foo.ml for the module Foo. In particular, filenames
like charInfo.ml and dVI.ml look extremely ugly to me. Is there any
reason why OCaml does not allow this?

In the patch below (relative to 3.04) I changed OCaml, when looking
for the module Foo, to first trying the file Foo.ml and, if
unsuccessful, to resort to foo.ml. If have used these modifications
for about a year without encountering any problems (w.r.t. compatibility
or otherwise).

Please, consider incorporating these changes in the next version.

Achim


                                                          | \_____/ |

Achim Blumensath \O/ ___/\ |
Mathematische Grundlagen der Informatik =o= \ /\ |
www-mgi.informatik.rwth-aachen.de/~blume /"\ o----|
___________________________________________________________________|

diff -urd ocaml-3.04/asmcomp/compilenv.ml ocaml-3.04-build/asmcomp/compilenv.ml
--- ocaml-3.04/asmcomp/compilenv.ml Fri Apr 21 10:10:30 2000
+++ ocaml-3.04-build/asmcomp/compilenv.ml Thu Dec 20 19:51:41 2001
@@ -109,7 +109,7 @@
let (approx, crc) =
try
let filename =

  •        find_in_path !load_path (String.uncapitalize modname ^ ".cmx") in
    
  •        find_in_path_uncapitalized !load_path (modname ^ ".cmx") in
         let (ui, crc) = read_unit_info filename in
         if ui.ui_name <> modname then
           raise(Error(Illegal_renaming(ui.ui_name, filename)));
    

diff -urd ocaml-3.04/debugger/source.ml ocaml-3.04-build/debugger/source.ml
--- ocaml-3.04/debugger/source.ml Thu Aug 10 11:58:07 2000
+++ ocaml-3.04-build/debugger/source.ml Thu Dec 20 19:51:41 2001
@@ -21,7 +21,7 @@
(*** Conversion function. ***)

let source_of_module mdle =

  • find_in_path !Config.load_path (String.uncapitalize mdle ^ ".ml")
  • find_in_path_uncapitalized !Config.load_path (mdle ^ ".ml")

(*** Buffer cache ***)

diff -urd ocaml-3.04/tools/ocamldep.ml ocaml-3.04-build/tools/ocamldep.ml
--- ocaml-3.04/tools/ocamldep.ml Tue Sep 25 11:54:14 2001
+++ ocaml-3.04-build/tools/ocamldep.ml Thu Dec 20 19:51:41 2001
@@ -278,9 +278,8 @@
let native_only = ref false

let find_dependency modname (byt_deps, opt_deps) =

  • let name = String.uncapitalize modname in
    try
  • let filename = Misc.find_in_path !load_path (name ^ ".mli") in
  • let filename = Misc.find_in_path_uncapitalized !load_path (modname ^ ".mli") in
    let basename = Filename.chop_suffix filename ".mli" in
    ((basename ^ ".cmi") :: byt_deps,
    (if Sys.file_exists (basename ^ ".ml")
    @@ -288,7 +287,7 @@
    else basename ^ ".cmi") :: opt_deps)
    with Not_found ->
    try
  • let filename = Misc.find_in_path !load_path (name ^ ".ml") in
  • let filename = Misc.find_in_path_uncapitalized !load_path (modname ^ ".ml") in
    let basename = Filename.chop_suffix filename ".ml" in
    ((basename ^ (if !native_only then ".cmx" else ".cmo")) :: byt_deps,
    (basename ^ ".cmx") :: opt_deps)
    diff -urd ocaml-3.04/typing/env.ml ocaml-3.04-build/typing/env.ml
    --- ocaml-3.04/typing/env.ml Sat Sep 29 00:55:27 2001
    +++ ocaml-3.04-build/typing/env.ml Thu Dec 20 19:51:41 2001
    @@ -147,7 +147,7 @@
    Hashtbl.find persistent_structures name
    with Not_found ->
    read_pers_struct name
  •  (find_in_path !load_path (String.uncapitalize name ^ ".cmi"))
    
  •  (find_in_path_uncapitalized !load_path (name ^ ".cmi"))
    

let reset_cache() =
Hashtbl.clear persistent_structures
diff -urd ocaml-3.04/utils/misc.ml ocaml-3.04-build/utils/misc.ml
--- ocaml-3.04/utils/misc.ml Thu Dec 28 14:07:42 2000
+++ ocaml-3.04-build/utils/misc.ml Thu Dec 20 19:51:41 2001
@@ -71,6 +71,12 @@
in try_dir path
end

+let find_in_path_uncapitalized path name =

  • try
  • find_in_path path name
  • with
  • | Not_found -> find_in_path path (String.uncapitalize name)

let remove_file filename =
try
Sys.remove filename
diff -urd ocaml-3.04/utils/misc.mli ocaml-3.04-build/utils/misc.mli
--- ocaml-3.04/utils/misc.mli Thu Dec 28 06:02:43 2000
+++ ocaml-3.04-build/utils/misc.mli Thu Dec 20 19:51:41 2001
@@ -37,6 +37,9 @@

val find_in_path: string list -> string -> string
(* Search a file in a list of directories. *)
+val find_in_path_uncapitalized: string list -> string -> string

  •    (* Search a file in a list of directories. If it isn't found the
    
  •       uncapitalized filename is tried. *)
    

val remove_file: string -> unit
(* Delete the given file if it exists. Never raise an error. *)
val expand_directory: string -> string -> string

@vicuna
Copy link
Author

vicuna commented Jun 3, 2002

Comment author: administrator

For aesthetic reasons (and being german) I prefer to capitalise
filenames, i.e., Foo.ml for the module Foo. In particular, filenames
like charInfo.ml and dVI.ml look extremely ugly to me. Is there any
reason why OCaml does not allow this?

No deep reasons, just historical baggage. I like your proposal to
support both Modulename.ml and modulename.ml, and will incorporate it
in the working sources if there's no opposition from other members of
the Caml team.

Best regards,

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented Apr 18, 2004

Comment author: administrator

Implemented in 3.07.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant