You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After some experiments that were inspired by issue #736, I think that the relation between Julia's constructors and gap_to_julia is more complicated than what we have at the moment.
Consider the following object L.
julia> using Oscar; using GAP; x = fmpz(10)^20; L = GAP.evalstr("List([1..10], i -> Julia.Main.x + i)");
This is a GAP list containing Julia objects. Now we want to convert this to a Julia array of GAP objects. The following works.
julia> [GapObj(x) for x in L]
10-element Vector{GapObj}:
GAP: 100000000000000000001
GAP: 100000000000000000002
[...]
The corresponding constructor does not work.
julia> Vector{GapObj}(L)
ERROR: Don't know how to convert value of type fmpz to type GapObj
Stacktrace:
[1] gap_to_julia(t::Type{GapObj}, x::fmpz)
[...]
The error message looks irritating: Oscar installs a method for converting fmpz to GapObj, see above.
The reason for the problem is that the constructor delegates to gap_to_julia with first argument Vector{GapObj} and with the wish to convert recursively; the method in question creates a Vector{GapObj} and wants to fill it with the results of gap_to_julia(GapObj, x) calls --but of course julia_to_gap would be the correct direction.
(And note that calling julia_to_gap(L) would not do what we want.)
My interpretation is that currently gap_to_julia promises a conversion in the direction from GAP to Julia, perhaps recursive (and then in this direction also for the subobjects), and if a Julia type is given as the first argument then this serves as a hint which conversion is intended but not as information about the direction of the conversion.
On the other hand, the constructor Vector{GapObj} promises a conversion to a Vector of GapObjs, which is impossible by delegation to the current gap_to_julia.
So what do we want:
change the recursions in gap_to_julia methods such that examples like the above one work,
separate the implementation of gap_to_julia from constructors where necessary, or
"reverse" the implementation such that gap_to_julia calls constructors, and not the other way round?
The text was updated successfully, but these errors were encountered:
After some experiments that were inspired by issue #736, I think that the relation between Julia's constructors and
gap_to_julia
is more complicated than what we have at the moment.Consider the following object
L
.This is a GAP list containing Julia objects. Now we want to convert this to a Julia array of GAP objects. The following works.
The corresponding constructor does not work.
The error message looks irritating: Oscar installs a method for converting
fmpz
toGapObj
, see above.The reason for the problem is that the constructor delegates to
gap_to_julia
with first argumentVector{GapObj}
and with the wish to convert recursively; the method in question creates aVector{GapObj}
and wants to fill it with the results ofgap_to_julia(GapObj, x)
calls --but of coursejulia_to_gap
would be the correct direction.(And note that calling
julia_to_gap(L)
would not do what we want.)My interpretation is that currently
gap_to_julia
promises a conversion in the direction from GAP to Julia, perhaps recursive (and then in this direction also for the subobjects), and if a Julia type is given as the first argument then this serves as a hint which conversion is intended but not as information about the direction of the conversion.On the other hand, the constructor
Vector{GapObj}
promises a conversion to aVector
ofGapObj
s, which is impossible by delegation to the currentgap_to_julia
.So what do we want:
change the recursions in
gap_to_julia
methods such that examples like the above one work,separate the implementation of
gap_to_julia
from constructors where necessary, or"reverse" the implementation such that
gap_to_julia
calls constructors, and not the other way round?The text was updated successfully, but these errors were encountered: