You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here I want to make an overview of two things: order of files in a project, order of declared symbols in a file.
Questions
Order of files: should the dependency graph of files be a tree, that is, if file A depends directly or indirectly on file B, should B be prohibited from depending directly or indirectly on A?
Order of files: if the order matters, should the included files be listed explicitly or automatically detect the order?
Order of symbols: can a function reference a symbol defined below in the file? Or maybe the order is the opposite?
C#
There's no order of files in C#. Any symbol within an assembly can reference any other assuming the visibility level allows.
C# Top-level statements
In C# top-level statements the following rules hold:
Any declared symbol can reference any other declared symbol (assuming the visibility allows).
Entrypoint code is in the top of the file.
Functions come strictly after entrypoint code.
Types come strictly after functions.
F#
Order of files matters. Symbols from file A can reference symbols from file B only if B is higher in the hierarchy.
The included files are listed explicitly in MSBuild (it's more of a tooling question perhaps, but it quite relates to the core of the language imo, especially given that MSBuild is the dominant build system for the .net langs).
Within a file, A can reference B only if B is defined above A.
Functions, types and values can be defined in any order within a file.
Each file has some number of modules or namespaces.
OCaml
1, 3, 4 are the same as in F#.
TODO: is it necessary to specify the order of files in OCaml default build system?
OCaml is shipped with ocamlopt which can figure out the correct order of files.
File = module
Rust
In Rust the order of the files doesn't matter, but they form a strong hierarchy based on the file structure. Each folder has a mod.rs, that's essentially the root of the subhierarchy. It declares and marks submodules to be exposed to the outside of this hierarchy. Anything else is basically inaccessible from the outside.
The text was updated successfully, but these errors were encountered:
I think that F# way is good. It makes it harder to accidentally make entities mutually recursive. Big projects tend to have dependencies grow extensively and it makes it harder to see actual flow. Rust way is good too, it allows to avoid namespaces like MyNamespace.Something.Internal.SomethingSpecific. Maybe something between will be the best
Here I want to make an overview of two things: order of files in a project, order of declared symbols in a file.
Questions
A
depends directly or indirectly on fileB
, shouldB
be prohibited from depending directly or indirectly onA
?C#
There's no order of files in C#. Any symbol within an assembly can reference any other assuming the visibility level allows.
C# Top-level statements
In C# top-level statements the following rules hold:
F#
A
can referenceB
only ifB
is defined aboveA
.OCaml
1, 3, 4 are the same as in F#.
TODO: is it necessary to specify the order of files in OCaml default build system?
ocamlopt
which can figure out the correct order of files.Rust
In Rust the order of the files doesn't matter, but they form a strong hierarchy based on the file structure. Each folder has a
mod.rs
, that's essentially the root of the subhierarchy. It declares and marks submodules to be exposed to the outside of this hierarchy. Anything else is basically inaccessible from the outside.The text was updated successfully, but these errors were encountered: