-
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
Support method dispatch based on tags (see the manual section "Tag Based Operations") #5344
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
@ChrisJefferson that's what I did and how I got the backtrace above. It unfortunately doesn't tell us much. I could easily break at it in gdb, I guess. But then what? |
This comment was marked as resolved.
This comment was marked as resolved.
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 looks good to me, just needs to be rebased. Perhaps some more people could look at the docs to see if they make sense.
lib/methsel.g
Outdated
## | ||
#F NewKeyBasedOperation( <name>, <requirements> ) | ||
#F DeclareKeyBasedOperation( <name>, <requirements> ) | ||
#F InstallKeyBasedMethod( <oper>[, <key>], <meth> ) |
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 am slightly concerned that people will confuse this with KeyDependentOperation
resp. confuse one with the other. So if someone has a good idea for an alternate name...
- added a new operation `DiagonalMatrix`, and added its documentation to the Reference Manual - added a new filter `IsRowVectorOrVectorObj`, analogous to `IsMatrixOrMatrixObj`, in order to simplify some method installations - moved the declarations of `DefaultVectorRepForBaseDomain` and `DefaultMatrixRepForBaseDomain` from `lib/matobj.gi` to `lib/matobj2.gd` - added a `CompatibleVectorFilter` method for `IsMatrix` object - added `NewZeroMatrix` and `NewIdentityMatrix` methods for `IsPlistRep` - added preliminary tests for `DiagonalMatrix` - removed some comment lines
as proposed in the discussion of gap-system#4398: - introduced `DeclareKeyBasedOperation`, `InstallKeyBasedMethod` (and `NewKeyBasedOperation`, in order to be able to write tests for them that can be run more than once in a session) - added a testfile - changed the code for `DiagonalMatrix` to use the setup given by the new functions (we could install methods depending on the representation but the main idea behind the change was that we do not have to do this) (Official documentation is still missing.)
15d9d91
to
98a973a
Compare
I'm generally happy with this PR. If you were looking for an alternative name to "Key", then I've often seen this kind of thing called "Tag". |
O.k., I will replace "key" by "tag". |
DiagonalMatrix
This is a follow-up of gap-system#5344, according to a comment in gap-system#4398.
In calls to operations such as
DiagonalMatrix
,CompanionMatrix
, etc., one wants to specify the internal representation of the result via a filter (such asIsPlistMatrixRep
) as the first argument. In order to be able to install individual methods depending on this filter, one does not really want to declare the operations as constructors because the result shall have exactly the given filter (and not perhaps something better), and also because one wants to be able to install a default method. (See the discussion of #4398 for details.)The changes proposed here provide an implementation (see commit 949cbc4) and documentation (see commit 9aaf40f) for this feature. Note that the operations in question are still GAP operations, the tag based mechanism is called only in the situation that the first argument is a filter.
The rest of the pull request applies the new mechanism to the operation
DiagonalMatrix
:DiagonalMatrix
, and added its documentation to the Reference ManualIsRowVectorOrVectorObj
, analogous toIsMatrixOrMatrixObj
, in order to simplify some method installationsDefaultVectorRepForBaseDomain
andDefaultMatrixRepForBaseDomain
fromlib/matobj.gi
tolib/matobj2.gd
CompatibleVectorFilter
method forIsMatrix
objectsNewZeroMatrix
andNewIdentityMatrix
methods forIsPlistRep
DiagonalMatrix
As soon as we agree on the details, the same changes can be applied to
PermutationMatrix
,ReflectionMatrix
,RandomMatrix
, see issue #4367.Here are the perhaps controversial pieces of the changes:
DiagonalMatrix( list )
behaves like the global functionDiagonalMat( list )
, and thenDiagonalMat
could become deprecated.IsPlistRep
matrices to be supported w.r.t. functionality for matrix objects. Thus perhaps the "auxiliary"NewZeroMatrix
andNewIdentityMatrix
methods forIsPlistRep
and theCompatibleVectorFilter
method forIsMatrix
objects are not what we want.