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

Refactoring: remove library interfaces #157

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

lefessan
Copy link
Member

@lefessan lefessan commented Feb 1, 2024

Library interfaces are generally a wrong good idea: it hides modules that could be useful later, it renames modules whose source files are then harder to locate, it may contain code that should be in other modules.

So, we must avoid them.

@lefessan lefessan force-pushed the z-2024-02-01-remove-library-interfaces branch from d5ebf47 to eb1016f Compare February 1, 2024 21:35
@lefessan lefessan force-pushed the z-2024-02-01-remove-library-interfaces branch from f87c264 to 03cf06f Compare February 1, 2024 22:32
@nberth nberth self-requested a review February 5, 2024 15:42
Copy link
Collaborator

@nberth nberth left a comment

Choose a reason for hiding this comment

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

As a whole this PR gathers some changes I adhere to, and some I am strongly opposed to:

  • I am against removing interface module in libraries that mostly define types and associated utilities (like the parse tree): I do not want to have to type Types all the time, while I still want to mention where the types are from in other libraries;
  • I am also against the renaming of many module names for which the prefix indicates where the module belongs to (Src_ and Preproc_ in the preprocessor, data_ in the types for representing the COBO data, etc). When editing files in various libraries at the same time, those prefixes are very useful. Complicated changes in the code often imply editing several libraries at the same time, so I think on the long run that outweighs the additional on-boarding cost.
  • I am in favor of removing the includes from interface modules (so, having Main modules that gather principal points).

All in all, I'd rather opt for a shortened version of this PR where the only remaining interface modules would be a list of module bindings that only remove their respective library-specific prefix (like Lsp_).

Copy link
Collaborator

Choose a reason for hiding this comment

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

all_types.ml would fit better with our naming scheme.

@@ -11,7 +11,7 @@
(* *)
(**************************************************************************)

open Lsp_project.TYPES
open Project.TYPES
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note Lsp_project defines an LSP-specific view on more general SuperBOL projects. Only having Project makes this quite unclear.

@@ -32,9 +32,9 @@ module TYPES = struct
}
and checked_doc = Cobol_typeck.Outputs.t
and rewinder =
(Cobol_ptree.compilation_group option,
(Cobol_ptree.Types.compilation_group option,
Copy link
Collaborator

Choose a reason for hiding this comment

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

cobol_ptree is a library that should define types and associated visitors and printers. For that one having tot type Types everywhere is very cumbersome. I am highly in favor of keeping the neat interface for that one.

Cobol_typeck.compilation_group ~config ptree |>
Cobol_typeck.translate_diagnostics ~config |>
Cobol_typeck.Engine.compilation_group ~config ptree |>
Cobol_typeck.Engine.translate_diagnostics ~config |>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe Main instead of Engine for cobol_typeck as well.

@@ -17,14 +17,15 @@ open Cobol_common (* Visitor *)
open Cobol_common.Srcloc.INFIX

open Lsp_completion_keywords
open Lsp.Types

module POSITION = Lsp.Types.Position
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that POSITION is highly confusing and makes the code below less readable. In this case I'd just remove that definition and always qualify with Lsp.Types..

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd keep Server_loop for that one, that's more precise.

@lefessan
Copy link
Member Author

lefessan commented Feb 9, 2024

FWIW, the subject is not whether we keep some package interfaces or not, we will get rid of all of them for readability and navigation issues. The question is more how to make it while keeping some consistency and ease of programming and qualifying things.

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

Successfully merging this pull request may close these issues.

2 participants