-
Notifications
You must be signed in to change notification settings - Fork 162
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
kernel: rename expression and statement "TNUMs" to avoid confusion with actual TNUMs #3422
Conversation
I would be totally happy with this PR, and also distinguishing stats and exprs is valid imho. I will try to fix #3371 soon (hopefully today or tomorrow) so we can get on with this. I assume you will leave the scripts in the PR, so I can apply them to other code I have already written using syntax trees? If not, it is also fine. |
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 entirely support the PR.
Maybe the script should check for the presence (and, if necessary the version) of perl and give a suitable error message if it's not there, just to minimise frustration.
Codecov Report
@@ Coverage Diff @@
## master #3422 +/- ##
==========================================
- Coverage 85.34% 85.34% -0.01%
==========================================
Files 699 699
Lines 346091 346092 +1
==========================================
- Hits 295373 295372 -1
- Misses 50718 50720 +2
|
@@ -330,7 +330,7 @@ static UInt ExecIfElifElse(Stat stat) | |||
** then 0 is returned. | |||
** | |||
** A for-loop with <n> statements in its body is represented by a bag of | |||
** type 'T_FOR' with <n>+2 subbags. The first subbag is an assignment bag | |||
** type 'STAT_FOR' with <n>+2 subbags. The first subbag is an assignment bag |
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.
There are still lots of these comments which claim that statements and expressions are "represented by a bag", and which talk about "subbags", and so on. I think it is out of scope for this PR, but it would be kinda nice to improve that.
E.g. instead of T_FUNCCALL_0ARGS we have EXPR_FUNCCALL_0ARGS, and instead of T_PROCCCALL_0ARGS we have STAT_PROCCCALL_0ARGS.
From my point of view, this could be merged now. |
I would be very happy if this can get merged. It conflicts with #3441 which I can update afterwards |
(This PR is motivated by repeated experiences trying to explain to people how GAP encodes function bodies. It is meant to make this code slightly more accessible.)
A long, long time ago, the statements and expressions which make up GAP function bodies were each coded as a separate GAP object. This is very inefficient for various reasons, so it was changed; now expressions and statements were simply a bunch of bytes within a single GAP object of type
T_BODY
, with a specific format. Yet they all retained their "identity" in the form of a type number, such asT_WHILE
to indicate a statement representing a while loop. To these day, the kernel code refers to these as "TNUMs".This can be rather confusing, as those TNUMs have nothing to do anymore with the GAP object TNUMs; yet they do not only still have the same name, but also they all share the same
T_
prefix. E.g. we haveT_STRING
(an object tnum) andT_STRING_EXPR
(an expression tnum).We discussed this on slack some time ago. The consensus seemed to be that we should rename these, turning the
T_
into eitherSTAT_
orEXPR_
, depending on the type.One alternative would be to use the same prefix for both, as there really is no difference between the two on a purely technical (low) level; the main importance for distinguishing the two cases is in validation of the coded function's structure, resp. whether in knowing which dispatch table to look when evaluating them. But for that it's not necessary to give them different names...
Alas, since a lot of code now tries hard to distinguish precisely between the two, I think it makes sense to go with the split here for now; if one day in the future we decided to unify expressions and statement terminology again, doing it for these "tnums" will be about the easiest part anyway ;-).
To perform the actual change, I wrote a little shell script, which I put into this PR. That makes it trivial to change things around: if we want another pair of prefixes: no problem. Also, if we merge some other PRs which will conflict with this PR (e.g. @sebasguts's PR #3371 which definitely should be merged before this PR), then it is trivial for me to recreate this PR.
Before this can be merged, some steps should be taken:
STAT_
prefix (there are none withEXPR_
prefix), namely:STAT_HEADER
STAT_MARK_CACHE
STAT_LVARS
STAT_LVARS_PTR