Skip to content

Commit

Permalink
Ensure all gap_to_julia method handle 'recursive' kwarg (#1115)
Browse files Browse the repository at this point in the history
... instead of relying on a dodgy catch-all method which handles that kwarg
  • Loading branch information
fingolfin authored Jan 7, 2025
1 parent cb8d2af commit bbdbe2b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 8 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

## Version 0.13.0-DEV (released YYYY-MM-DD)

- Update to GAP 4.14.0
- **Breaking:** Update to GAP 4.14.0
- **Breaking:** Require `gap_to_julia` methods to handle `recursive`
keyword argument (e.g. by adding `; recursive::Bool = true` to the
argument list and otherwise ignoring it)
- Add `GAP.Packages.build_recursive(name)`
- Add `GAP.Packages.test(name)`
- Change `GAP.Packages.build(name)` to no longer try to build the package if
it is already installed
- Instead of downloading a single huge "artifact" containing all deposited GAP
packages, we now use (and download) one artifact per GAP package.
- Use individual artifacts for each GAP package distributed with GAP,
instead of a single huge "artifact" containing all of them and which
has to be downloaded for each update (now we can update GAP packages
individually)
- Use precompiled binaries for the following GAP packages:
- 4ti2interface
- ace
Expand Down
10 changes: 4 additions & 6 deletions src/gap_to_julia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ The following `gap_to_julia` conversions are supported by GAP.jl.
| `IsMatrixObj` | `Matrix{Any}` | `Matrix{T}` |
| `IsRecord` | `Dict{Symbol, Any}` | `Dict{Symbol, T}` |
"""
function gap_to_julia(t::T, x::Any) where {T<:Type}
function gap_to_julia(t::T, x::Any; recursive::Bool = true) where {T<:Type}
## Default for conversion:
## Base case for conversion (least specialized method): Allow converting any
## Julia object x to type T, provided that the type of x is a subtype of T;
Expand All @@ -110,12 +110,10 @@ function gap_to_julia(t::T, x::Any) where {T<:Type}
return x
end

## Switch recursion on by default.
## If no method for the given arguments supports 'recursion_dict'
## then assume that it is not needed.
gap_to_julia(type_obj, obj, recursion_dict::Union{Nothing,RecDict}; recursive::Bool = true) =
gap_to_julia(type_obj, obj; recursive)
gap_to_julia(type_obj, obj; recursive::Bool = true) = gap_to_julia(type_obj, obj)

## Default
gap_to_julia(::Type{Any}, x::GapObj; recursive::Bool = true) =
Expand Down Expand Up @@ -295,8 +293,8 @@ function gap_to_julia(
end

## Ranges
gap_to_julia(::Type{T}, obj::GapObj) where {T<:UnitRange} = T(obj)
gap_to_julia(::Type{T}, obj::GapObj) where {T<:StepRange} = T(obj)
gap_to_julia(::Type{T}, obj::GapObj; recursive::Bool = true) where {T<:UnitRange} = T(obj)
gap_to_julia(::Type{T}, obj::GapObj; recursive::Bool = true) where {T<:StepRange} = T(obj)

## Dictionaries
function gap_to_julia(
Expand Down Expand Up @@ -326,7 +324,7 @@ function gap_to_julia(
end

## Generic conversions
gap_to_julia(x::Any) = x
gap_to_julia(x::Any; recursive::Bool = true) = x

function gap_to_julia(x::GapObj; recursive::Bool = true)
GAP_IS_INT(x) && return gap_to_julia(BigInt, x)
Expand Down

0 comments on commit bbdbe2b

Please sign in to comment.