-
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
Idea: record location of InstallMethod
call
#2239
Comments
I have some prototype code that does this (in multiple variations). My first incarnation had a global variable that complemented the I think an approach similar to |
Well, I assume we'd have to add one more entry per method into each |
For now, we print the location of the *method*. Ideally, we should instead track the location of the InstallImmdiateMethod call. See also issue gap-system#2239.
For now, we print the location of the *method*. Ideally, we should instead track the location of the InstallImmdiateMethod call. See also issue gap-system#2239. Before: gap> TraceImmediateMethods( ); gap> g:= Group( (1,2,3), (1,2) );; After: gap> TraceImmediateMethods( ); gap> g:= Group( (1,2,3), (1,2) );;
For now, we print the location of the *method*. Ideally, we should instead track the location of the InstallImmdiateMethod call. See also issue gap-system#2239. Before: gap> TraceImmediateMethods( ); gap> g:= Group( (1,2,3), (1,2) );; #I immediate: Size #I immediate: IsCyclic #I immediate: IsCommutative #I immediate: IsTrivial After: gap> TraceImmediateMethods( ); gap> g:= Group( (1,2,3), (1,2) );; #I RunImmediateMethods #I immediate: Size at GAPROOT/lib/coll.gi:174 #I immediate: IsCyclic at GAPROOT/lib/grp.gi:34 #I immediate: IsCommutative at GAPROOT/lib/magma.gi:190 #I immediate: IsTrivial at GAPROOT/lib/magma.gi:124
For now, we print the location of the *method*. Ideally, we should instead track the location of the InstallImmediateMethod call. See also issue gap-system#2239. Before: gap> TraceImmediateMethods( ); gap> g:= Group( (1,2,3), (1,2) );; #I immediate: Size #I immediate: IsCyclic #I immediate: IsCommutative #I immediate: IsTrivial After: gap> TraceImmediateMethods( ); gap> g:= Group( (1,2,3), (1,2) );; #I RunImmediateMethods #I immediate: Size at GAPROOT/lib/coll.gi:174 #I immediate: IsCyclic at GAPROOT/lib/grp.gi:34 #I immediate: IsCommutative at GAPROOT/lib/magma.gi:190 #I immediate: IsTrivial at GAPROOT/lib/magma.gi:124
For now, we print the location of the *method*. Ideally, we should instead track the location of the InstallImmediateMethod call. See also issue gap-system#2239. Before: gap> TraceImmediateMethods( ); gap> g:= Group( (1,2,3), (1,2) );; #I immediate: Size #I immediate: IsCyclic #I immediate: IsCommutative #I immediate: IsTrivial After: gap> TraceImmediateMethods( ); gap> g:= Group( (1,2,3), (1,2) );; #I RunImmediateMethods #I immediate: Size at GAPROOT/lib/coll.gi:174 #I immediate: IsCyclic at GAPROOT/lib/grp.gi:34 #I immediate: IsCommutative at GAPROOT/lib/magma.gi:190 #I immediate: IsTrivial at GAPROOT/lib/magma.gi:124
For now, we print the location of the *method*. Ideally, we should instead track the location of the InstallImmediateMethod call. See also issue gap-system#2239. Before: gap> TraceImmediateMethods( ); gap> g:= Group( (1,2,3), (1,2) );; #I immediate: Size #I immediate: IsCyclic #I immediate: IsCommutative #I immediate: IsTrivial After: gap> TraceImmediateMethods( ); gap> g:= Group( (1,2,3), (1,2) );; #I RunImmediateMethods #I immediate: Size at GAPROOT/lib/coll.gi:174 #I immediate: IsCyclic at GAPROOT/lib/grp.gi:34 #I immediate: IsCommutative at GAPROOT/lib/magma.gi:190 #I immediate: IsTrivial at GAPROOT/lib/magma.gi:124
This makes the information displayed by TraceMethods and by ApplicableMethod much more useful in many case, which resolves gap-system#2239. For example, consider this method for `AsList`, installed in coll.gi: InstallMethod( AsList, "for collections that are constant time access lists", [ IsCollection and IsConstantTimeAccessList ], Immutable ); With GAP 4.8, no location information is shown at all: gap> TraceMethods(AsList); AsList("abc");; #I AsList: for collections that are constant time access lists With GAP 4.9 / master, the location where the method (i.e., the underlying function) was defined is shown, which already does the job in many cases, but not here: gap> TraceMethods(AsList); AsList("abc");; #I AsList: for collections that are constant time access lists at src/objects.c:fail With this PR, we get this (note that instead of GAPROOT, the actual path is printed) gap> TraceMethods(AsList); AsList("abc");; #I AsList: for collections that are constant time access lists at GAPROOT/lib/coll.gi:302
This makes the information displayed by TraceMethods and by ApplicableMethod much more useful in many case, which resolves gap-system#2239. For example, consider this method for `AsList`, installed in coll.gi: InstallMethod( AsList, "for collections that are constant time access lists", [ IsCollection and IsConstantTimeAccessList ], Immutable ); With GAP 4.8, no location information is shown at all: gap> TraceMethods(AsList); AsList("abc");; #I AsList: for collections that are constant time access lists With GAP 4.9 / master, the location where the method (i.e., the underlying function) was defined is shown, which already does the job in many cases, but not here: gap> TraceMethods(AsList); AsList("abc");; #I AsList: for collections that are constant time access lists at src/objects.c:fail With this PR, we get this (note that instead of GAPROOT, the actual path is printed) gap> TraceMethods(AsList); AsList("abc");; #I AsList: for collections that are constant time access lists at GAPROOT/lib/coll.gi:302
This makes the information displayed by TraceMethods and by ApplicableMethod much more useful in many case, which resolves #2239. For example, consider this method for `AsList`, installed in coll.gi: InstallMethod( AsList, "for collections that are constant time access lists", [ IsCollection and IsConstantTimeAccessList ], Immutable ); With GAP 4.8, no location information is shown at all: gap> TraceMethods(AsList); AsList("abc");; #I AsList: for collections that are constant time access lists With GAP 4.9 / master, the location where the method (i.e., the underlying function) was defined is shown, which already does the job in many cases, but not here: gap> TraceMethods(AsList); AsList("abc");; #I AsList: for collections that are constant time access lists at src/objects.c:fail With this PR, we get this (note that instead of GAPROOT, the actual path is printed) gap> TraceMethods(AsList); AsList("abc");; #I AsList: for collections that are constant time access lists at GAPROOT/lib/coll.gi:302
This makes the information displayed by TraceMethods and by ApplicableMethod much more useful in many case, which resolves gap-system#2239. For example, consider this method for `AsList`, installed in coll.gi: InstallMethod( AsList, "for collections that are constant time access lists", [ IsCollection and IsConstantTimeAccessList ], Immutable ); With GAP 4.8, no location information is shown at all: gap> TraceMethods(AsList); AsList("abc");; #I AsList: for collections that are constant time access lists With GAP 4.9 / master, the location where the method (i.e., the underlying function) was defined is shown, which already does the job in many cases, but not here: gap> TraceMethods(AsList); AsList("abc");; #I AsList: for collections that are constant time access lists at src/objects.c:fail With this PR, we get this (note that instead of GAPROOT, the actual path is printed) gap> TraceMethods(AsList); AsList("abc");; #I AsList: for collections that are constant time access lists at GAPROOT/lib/coll.gi:302
Right now, one can use e.g.
LocationFunc
orPageSource
on methods installed for an operation, which is quite handy. But sometimes the same function is installed several times; or a kernel function is installed as a method (possibly also several times), and in these cases, the location of the function definition does not coincide with the location of the method installation.Thus, it would be nice if we could store the location of the method installation, too. I assume it could be e.g. stored in the methods array, along with the other methods.
The tricky part might be to figure out the location itself. I assume this may require some work on the kernel to be possible. We'd somehow need to retrieve the location of the place
InstallMethod
was called... Perhaps some clever lvar walking can help?!? humThe text was updated successfully, but these errors were encountered: