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

problem with conversion from GAP to a prescribed Julia type? #167

Closed
ThomasBreuer opened this issue Nov 22, 2018 · 3 comments
Closed

problem with conversion from GAP to a prescribed Julia type? #167

ThomasBreuer opened this issue Nov 22, 2018 · 3 comments
Labels
topic: conversion Issue related to conversion

Comments

@ThomasBreuer
Copy link
Member

In order to create a Julia array of strings from a GAP list of strings, one can do the following.

gap> l:= [ "a" ];;  arr1:= GAPToJulia( l );
<Julia: Any["a"]>
gap> arr2:= Julia.Base.convert( JuliaEvalString( "Array{String,1}" ), arr1 );
<Julia: ["a"]>
gap> JuliaTypeInfo( arr1 );
"Array{Any,1}"
gap> JuliaTypeInfo( arr2 );
"Array{String,1}"

When I try to skip the intermediate step, by giving the intended type information to GAPToJulia,
I get the following.

gap> GAPToJulia( JuliaEvalString( "Array{String,1}" ), l );
Error, StackOverflowError:
not in any function at *stdin*:13
type 'quit;' to quit to outer loop
@fingolfin
Copy link
Member

Heh, and the Julia version leads to a nice segfault:

julia> l = GAP.EvalString(""" l:= [ "a" ];; """)[1][2]
GAP: [ "a" ]

julia> GAP.gap_to_julia( Array{String,1}, l )
Bus error: 10

@fingolfin
Copy link
Member

OK, so part of the problem is that we actually don't have a conversion to String, only to AbstractString. Both examples work if one replaces String by AbstractString.

But if one specifies an unsupported conversion, the system currently runs into an infinite recursion (see also issue #165), and then sometimes Julia manages to catch it, and sometimes not (because GAP also deepens the call stack)

@sebasguts
Copy link
Contributor

So, a quick fix is replacing the AbstractString in gap_to_julia with String.

The current return type of the conversion to AbstractString is String anyway, so I would guess having a fallback there is also no problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: conversion Issue related to conversion
Projects
None yet
Development

No branches or pull requests

3 participants