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

File inclusion outside of top level #90

Closed
tirix opened this issue May 24, 2022 · 3 comments
Closed

File inclusion outside of top level #90

tirix opened this issue May 24, 2022 · 3 comments

Comments

@tirix
Copy link
Collaborator

tirix commented May 24, 2022

One of the optimisations making metamath-knife fast is to use multi-threading. This means that databases are split into segments, and each segment is then handled completely separately, in a different thread.

The segments themselves are chosen to be at the start of main chapters, and at file inclusions. In order to allow this, a note in parser.rs mentions:

We require file inclusions to be between statements at the top nesting level (this has been approved by Norman Megill).

That requirement is also stated in the Metamath Book, chapter 4.1.2, but depending on the discussion in Metamath.exe#85, we might prefer to allow file inclusion outside of the top level.

I'm opening this issue to discuss how this limitation could be removed. It might be possible to allow file inclusion at any position outside of other statements, so that placing a file inclusion outside of the top level would only mean that metamath-knife would not be optimally efficient.

The UnclosedBeforeInclude would need to be changed into a warning that parsing is not optimal.

@digama0
Copy link
Member

digama0 commented May 24, 2022

Independently of implementation issues, I think it is bad design-wise to have inclusions not at the top level, because then it means that things in the included file that appear to be at the top level are not actually at the top level, which makes it harder to understand scoping across files. I have never heard of a programming language which allows that sort of thing.

@tirix
Copy link
Collaborator Author

tirix commented May 24, 2022

Two examples I can immediately think of are C and PHP:

If the include occurs inside a function within the calling file, then all of the code contained in the called file will behave as though it had been defined inside that function. So, it will follow the variable scope of that function.

Both allow it technically, but I think anyone would argue it's really bad.
I'll close this issue for now.

@tirix tirix closed this as completed May 24, 2022
@tirix tirix closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2022
@digama0
Copy link
Member

digama0 commented May 24, 2022

Yeah, I was tactfully avoiding mentioning the C include behavior, which is lexer level similar to metamath.c's implementation and so lets you do some horrible horrible things like includes in string constants...

I think it is generally a side effect of very dynamic languages that just implement it "operationally" and don't think too hard about the meaning of the construct in terms of declarative code structuring.

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

No branches or pull requests

2 participants