-
Notifications
You must be signed in to change notification settings - Fork 1
FunC global variables and compiler directives pages #687
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
base: main
Are you sure you want to change the base?
Conversation
To fix the formatting issues:
npx remark -o --silent --silently-ignore language/func/compiler-directives.mdx language/func/global-variables.mdx |
Thanks for the updates across the FunC docs, especially in compiler directives and global variables. I found several high‑severity doc issues that should be fixed before merge. Findings (5)High (5)[HIGH] Undefined placeholder in example (
|
@@ -15,7 +15,7 @@ The `#include` directive enables the inclusion of another FunC source file parse | |||
**Syntax:** | |||
|
|||
```func | |||
#include "filename.fc"; | |||
#include "<path_to_filename>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it allow cyclic includes, i.e. when some file imports itself, directly or indirectly?
sidebarTitle: "Global variables" | ||
noindex: "true" | ||
--- | ||
|
||
A FunC program primarily consists of function declarations/definitions and global variable declarations. | ||
This section focuses on the latter. | ||
## Declaration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice reference article, except it doesn't answer several key questions:
- What does it mean for a variable to be global? (i.e. it's stored in a certain control register as part of tuple)
- Why would someone want to make a variable global?
- What if there are 2 global variables with the same in different files?
- What if the same file with a global variable is included twice?
|
||
Under the hood, global variables in FunC are stored in the `c7` control register of the TVM, with a maximum limit of 31 variables. | ||
In FunC, you can _omit the type_ of global variables. In this case, the compiler determines the type based on how the variable is used. Equivalently, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think this is applicable to arbitary variable declarations, and should just link to a corresponding section of documentation about variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not do this because local variables and global variables are completely different entities in FunC. Local variable declarations are expressions, while global variable declarations are not. There are also other differences, for example global variables can omit the type, but local variables do not allow this. So, I prefer to leave them on their own page independently one from another.
…ntlify-ton-docs into jeshecdom/core-rest
Closes #686. Closes #685.