-
Notifications
You must be signed in to change notification settings - Fork 165
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
Additional Type Information #1236
Conversation
Actually this is missing a function to query the declaration location. I'll add this. |
e39b3d4
to
6946543
Compare
The |
6946543
to
010fb3f
Compare
Codecov Report
@@ Coverage Diff @@
## master #1236 +/- ##
==========================================
- Coverage 63.98% 61.71% -2.27%
==========================================
Files 995 911 -84
Lines 325334 267762 -57572
Branches 13032 13036 +4
==========================================
- Hits 208155 165254 -42901
+ Misses 114381 99825 -14556
+ Partials 2798 2683 -115
|
* IsCategory, IsProperty, IsAttribute determine wheter an object is a category, property, or attribute respectively * FilterByName retrieve filter by name * IdOfFilter return the ID of a given filter * IdOfFilterByName return the ID if a filter given by its name * CategoryByName return category by name
Functionality to store the location of the declaration of * filters * operations * attributes * properties
010fb3f
to
865d99d
Compare
I rebased this and tweaked it a tiny bit. It would be good to get some feedback; I'll probably discover more things I would like to be able to do with objects and types later. |
I'll fix the HPC-GAP failures. |
fi; | ||
fi; | ||
|
||
fid := PositionProperty(BIND_LOCS, x -> x[1] = NAME_FUNC(object)); |
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 wonder if we really need all that: our filters and operation are T_FUNCTION
objects internally, and thus FILENAME_FUNC
and LOCATION_FUNC
(resp. STARTLINE_FUNC
/ ENDLINE_FUNC
) are applicable for them. These slots are currently never set for filters & operations, as far as I can tell...
So can't we just add SET_*
counterparts for these to the kernel interface, and store the information in there?
Perhaps I am missing something?
gap> IsProperty(IsFinite); | ||
true | ||
gap> IsOperation(IsFinite); | ||
true |
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.
Perhaps do this instead (which I find a bit easier to read, esp. as I don't need to scroll around as much; and testing more things later one becomes easier?)
gap> test := x -> List([IsFilter, IsCategory, IsAttribute, IsProperty, IsOperation], f -> f(x));;
gap> test(IsFinite)
[ true, false, true, true, true ]
...
gap> IsProperty(Size); | ||
false | ||
gap> IsOperation(Size); | ||
true |
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.
So... should there also be negative tests, i.e. for what happens if one applies IsFilter
to, say, a boolean, or a string, or ... ?
## | ||
## <Description> | ||
## finds the id of the filter, or the filter with name <A>name</A> respectively, | ||
## in the global FILTERS list. |
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 think it would be good to explain here why FilterByName
is useful -- at first glance, x := FilterByName("IsFinite");
is just a longer way of saying x := IsFinite
. But of course it's possible to have filters which are not bound to a global variable with matching names. So perhaps state just that: That a filter has an intrinsic name, and there need not be a global variable with matching name; and even if there is such a gvar, it need not be bound to that filter.
Also perhaps have a "see also" ref pointing to CategoryByName
?
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.
Perhaps another reason would be that a filter can be named Tester(FOO)
, which is not a valid gvar identifier. Of course we now changed that particular example, but the general problem remains (and is solved by FilterByName
, I guess)
## <Func Name="FilterByName" Arg="name"/> | ||
## | ||
## <Description> | ||
## finds the id of the filter, or the filter with name <A>name</A> respectively, |
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.
My first thought was "what is the id of a filter"? I only later saw IdOfFilter
below. I'd therefore recommend splitting the documentation of IdOfFilterByName
and FilterByName
. The former might start like this:
"find the id of the given filter, as defined in IdOfFilter
.
flags := []; | ||
fi; | ||
flafs := FLAGS_FILTER(op); | ||
if flafs <> false then |
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.
Missing indentation? Perhaps you did this so as to not obscure the review with pointless whitespace diffs?
fi; | ||
flafs := FLAGS_FILTER(op); | ||
if flafs <> false then | ||
flags := TRUES_FLAGS(FLAGS_FILTER(op)); |
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.
Perhaps you meant to use flafs
here, too? Otherwise you could just as well get rid of it again.
fi; | ||
od; | ||
return fail; | ||
end); |
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.
So this function is essentially equivalent to name -> PositionProperty(FILTERS, f -> NAME_FUNC(f) = name)
? Of course PositionProperty
is not available at the time this file is read. But it makes me wonder how useful this function really is... seem to me mostly something for core developers? Perhaps you are concerned about this helper being available very early on? Because if not, then I'd consider going with the much shorter definition, and simply defining this in a new filter lib/filter.gi
else | ||
return fail; | ||
fi; | ||
end); |
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.
Similarly, this is name -> First(FILTERS, f -> NAME_FUNC(f) = name);
narg, | ||
flags, | ||
rank, | ||
rec( line := INPUT_LINENUMBER(), file := INPUT_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.
So what does this add compared to FILENAME_FUNC(method)
? The location the method is installed? So that would differ for the few instances were a function is defined in one place, and then installed in another? That seems somewhat rare... But in any case: If I guess right, then this should be explicitly documented, instead of leaving the reader to wonder.
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.
Also, a test case showing the difference would be nice?
This needs to be rebased. |
I think actually this is now obsolete: The helper functions have been added in #1593, and the location information should be stored in the function object; this just requires a little more work (which we discussed elsewhere). |
So if this is obsolete, shall we close it? |
This pull request does 2 things
IsCategory
,FilterByName
,IdOfFilter
,IdOfFilterByName
, andCategoryByName
.