Skip to content
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

Implement convenience functions in Julia and in GAP for doing many common basic operations #79

Closed
fingolfin opened this issue Oct 16, 2018 · 7 comments
Labels
kind: enhancement New feature or request

Comments

@fingolfin
Copy link
Member

It would be very convenient if there were default Julia implementations for getindex, setindex!, getproperty, setproperty! that work on any GapObj (and raise an error if not applicable).

Here is some untested rough draft (without a working LibGAP.jl, it is a bit annoying to work on this)

# lists
getindex(x::GapObj, i::Int) = GAP.GAPFuncs.ELM_LIST(x, to_gap(i))
setindex!(x::GapObj, v, i::Int) = GAP.GAPFuncs.ASS_LIST(x, to_gap(i), to_gap(v))

# matrix
getindex(x::GapObj, i::Int, j::Int) = GAP.GAPFuncs.ELM_LIST(x, to_gap(i), to_gap(j))
setindex!(x::GapObj, v, i::Int, j::Int) = GAP.GAPFuncs.ASS_LIST(x, to_gap(i), to_gap(j), to_gap(v))

# records
RNamObj(f::Symbol) = GAP.GAPFuncs.RNamObj(to_gap(string(f)))
getproperty(x::GapObj, f::Symbol) = GAP.GAPFuncs.ELM_REC(x, RNamObj(f))
setproperty!(x::GapObj, f::Symbol, v) = GAP.GAPFuncs.ASS_REC(x, RNamObj(f), to_gap(v))
@ThomasBreuer
Copy link
Member

ThomasBreuer commented Oct 23, 2018

Generic Julia methods would make sense also for append!, push!, show (here we get again the request for a working ViewString like feature in GAP),
and also for ==, <, +, -, *, /, ^, mod.

@fingolfin
Copy link
Member Author

I think @sebasguts added the former, but the latter is still missing (as I just discovered). Also, none of this is being tested right now.

@fingolfin
Copy link
Member Author

Another generic method: string.

And all of these also should apply for GapFFE, too.

@fingolfin fingolfin added the kind: enhancement New feature or request label Nov 1, 2018
@fingolfin fingolfin changed the title Implement getindex, setindex!, getproperty, setproperty! for GapObj Implement convenience functions in Julia and in GAP for doing many common basic operaitons Nov 1, 2018
@fingolfin fingolfin changed the title Implement convenience functions in Julia and in GAP for doing many common basic operaitons Implement convenience functions in Julia and in GAP for doing many common basic operations Nov 1, 2018
@fingolfin
Copy link
Member Author

In addition, the converse would also be nice: I.e. to have methods for \[\], \=, \< etc. in GAP for Julia objects.

@fingolfin
Copy link
Member Author

I just noticed that JuliaExperimental provides the latter (GAP helpers to map + to Julia's +, etc.) in its arith.gi file. Now I wonder if that shouldn't be moved to JuliaInterface?

@sebasguts
Copy link
Contributor

Either that, yes, or add those arithmetics to the GAP dispatch tables using julia's @cfunction.

@fingolfin
Copy link
Member Author

We moved the GAP wrappers for Julia arithmetic to JuliaInterface in PR #132. So far it is purely on the GAP level. We could of course looking into also doing it via the GAP dispatch tables, though it's not completely clear to me that this would be worth it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants