-
Notifications
You must be signed in to change notification settings - Fork 160
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
Make ValueGlobal faster #2232
Make ValueGlobal faster #2232
Conversation
Looks like @stevelinton may have written this file originally. My main comment is that I don't really like just doing this to ValueGlobal, when there are many other functions in the same file (IsBoundGlobal, MakeReadOnlyGlobal,...), which all have a similar design to ValueGlobal. I would prefer we simplify all of them, or none of them, unless there is a good reason to just change one. |
That was me. A very long time ago. I don't really like the use of |
Codecov Report
@@ Coverage Diff @@
## master #2232 +/- ##
==========================================
- Coverage 69.88% 69.88% -0.01%
==========================================
Files 481 481
Lines 252990 252986 -4
==========================================
- Hits 176814 176805 -9
- Misses 76176 76181 +5
|
lib/global.gd
Outdated
@@ -61,7 +61,7 @@ DeclareGlobalFunction("IsValidIdentifier"); | |||
## </Description> | |||
## </ManSection> | |||
## | |||
DeclareGlobalFunction("ValueGlobal"); | |||
DeclareSynonym("ValueGlobal", VALUE_GLOBAL); |
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 agree with @stevelinton : I'd leave this declaration here, and then just change the .gi
file to InstallGlobalFunction( ValueGlobal, VALUE_GLOBAL )
, simply for symmetry with the rest.
The difference is in the function names:
gap> DeclareSynonym("foo", VALUE_GLOBAL);
gap> DeclareGlobalFunction("bar");
gap> InstallGlobalFunction( bar, VALUE_GLOBAL );
gap> NameFunction(foo);
"VAL_GVAR"
gap> NameFunction(bar);
"bar"
Which reminds me of another thing: VALUE_GLOBAL
itself is just an alias for VALUE_GVAR
, and it is not even write protected: You can e.g. do VALUE_GLOBAL := 1
...
So we may want to unify that, too. But of course we have to be careful because there are packages using almost any of the three names in provided for each of the functions dealing with globals sigh. (Strictly speaking, packages using the undocumented functions VALUE_GLOBAL
, VALUE_GVAR
etc are doing something wrong, and we are not responsible for keeping them working, but, well, let's be realistic, people will still yell at us, not the package authors, if we change this without either providing backward compatibility code, or else getting all packages using it fixed first....
and made it a synonym for VALUE_GLOBAL
I adjusted the commit and the PR to @stevelinton 's suggestions. I also agree completely to @ChrisJefferson 's suggestions, by making that change to many of the functions in |
@sebasguts thanks, but now the commit message does not fit :-). I think the commit message should mention that calling BTW, while I won't miss the Anyway, if people were to miss it, I wonder if just removing the call to Final remark: While I do not expect you to make other changes, I'd like to point out that most other |
@fingolfin Why does the message not fit? It is still a synonym, just not in the technical sense. But I can change it if you like. Then I can also point out why the call is not necessary. I also generally agree that the call for |
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.
OK, I guess the commit message is fine after all.
I have approved this PR, but I'd like @ChrisJefferson and/or @stevelinton to decide its ultimate fate for now. |
... by turning
ValueGlobal
into a synonym ofVALUE_GLOBAL
.The check if the argument of
ValueGlobal
is a string is done byVALUE_GLOBAL
, too, so this check is not necessary.The fact if all characters in the argument string are in
IdentifierLetters
does not cause an error, just an info. Furthermore, variables with different characters in their identifier, e.g.,\
, can still be written to and accessed.