-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add import statement #18
Conversation
It looks like the build failing isn't related to this PR. |
It is nice to see somebody giving documentation much needed attention. The way it is written it seems like one should never use include so it begs the question of why does include exist? Legacy is not a good reason because valid code from before import existed is now rendered invalid.
Why are there two separate pragma once systems? Is it possible for both to use one system or is it necessary to keep them separate? I don't know, but this is potentially going to confuse people so it is probably worth checking into unifying the two systems if possible. |
Hi paxcut! Thanks for your remarks.
That's what was my understanding when I wrote this. I thought Because of that, the
Good tip! I didn't know about this. We can mention this. So, I don't have a picture where's the place for
I don't know enough to answer these. |
ok, Lets start from the beginning from before import was even first discussed let alone implemented. include was the only way to incorporate code from other files. It was fully functional and every system file that needed content from another one used include. pragma once is a directive designed to work with include to avoid multi-inclusions, just as it is for c/c++. That exact same system (or its equivalent but that's another story) is still in place today completely intact except the part where every system file includes other system files, now they import them. When import was designed and implemented as a language statement it was decided that instead of creating an import guard that functions at the statement level,import would 'borrow' the directive system but due to the differing locations and times where directives and statements are processed they couldn't share the data of what had been already used and what had not. As a consequence of that design decision and the later move of all system files to import left include crippled in many ways. So how are the two systems similar and how do they differ? I wrote a little blurb about it in discord.If you have problems getting to read my comment or questions after reading it let me know and will try to answer as much as I can. Thanks for listening! |
Add a link in the SUMMARY.md Add the relevant parts of the new page from the preprocessor.md page. Add dots to some paragraphs missing one in preprocessor.md.
Thanks for the link @paxcut! I scrolled to the top of the discussion to get more context. I expanded on all the ins and outs I found out about |
That is very good. You have a talent for expressing the complex in a simple way. Very impressive. There are some things I am not 100% sure how they really work.I know compilation units don't share directives, but as for variables they may be able to share variables defined in the global scope and in pattern language there are no 'local' variables in the global scope. That may seem confusing but all i'm saying is that every variable that's not part of a function or a user-defined type is a global variable. Even variables defined in the global scope of a namespace are also defined elsewhere and there is no scope resolution operator that applies to variables (only for types). Some experimentation I did clearly shows that if you include or import a file the defines a global variable and try to define it again results in a duplicated definition error. and that the value the variable had in the included file remains the same. the sentence
is grammatically incorrect, it should be
|
Co-Authored-By: paxcut <[email protected]>
As we discussed on Discord, I am now submitting an initial version of the
import
statement documentation. All suggestions are welcome.Fixes: #15.
Fixes: #11.
I am not sure if this is considered controversial, but adding a folder with multiple of your pattern files to the search paths using
Extras > Settings > Folders
will allow the user to correctlyimport
their pattern files to other pattern files. If I understand the request/issue correctly, that's also the point of the issue: WerWolv/ImHex-Patterns#269Edit: I think it also fixes: WerWolv/ImHex#1641 since ImHex won't crash anymore in that issue, and this PR explains how to properly use standard library headers.