GAP.jl
GAP.jl copied to clipboard
Macro construct bug?
x = @gap (1, 2)(3,4) # error
x = GAP.EvalString("(1,2)(3,4)") # OK
Thanks for this report.
By putting show( str )
into the macro definition,
one sees that the argument is :(((1, 2, 3))(4,5))
inside the macro.
That is, Julia has silently inserted a pair of brackets around the first cycle,
and this syntax cannot be parsed by GAP.
This addition of brackets does not happen if there is only one cycle,
and more brackets get added if the number of cycles increases.
I do not know how to fix this behaviour.
(Of course, one can write `@gap "(1,2)(3,4)".)
As far as I remember, I already realized when implementing this macro that it does not have the same power as the EvalString
method. It may be used for some conveniences, but should not really be used in any functions or so.
That said, I do not think this actually can be fixed. The gap string type also works better.
This is a known limitation.
For permutations in particular, I plan to add a macro in the future which works via a trick: Basically, you can parse (1,2)(3,4)
in Julia as an attempt to call the tuple (1,2)
as if it was a function, with arguments 3,4
; so we get a valid AST for it; all that remains is to add a code transformation which allows us to extract the the cycles, and then we can call GAP to construct the actual permutation.