-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Autogeneration of pari declarations #28
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too weak.
autogen/pari_decl.py
Outdated
line = line.replace('(void);', '();') | ||
|
||
# lambda is not a valid variable name in Cython | ||
line = line.replace('long *lambda', 'long *') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not robust! A declaration like long *lambdaf(void);
would be wrongly modified! Would be better to check for the specific line it is intended for
GEN ZX_ZXY_rnfequation(GEN A, GEN B, long *lambda);
811e9c6
to
34dda22
Compare
Maybe the "cdef extern from *" could be made more explicit? |
It could. However, having this more explicit will include a
@jpflori I would be happy with something more general. However, you need to catch or not catch various subtle differences. Namely catch
but do not catch
Do you think it is worth the trouble? |
I would keep these two independent. Keep the old |
What do you mean!? You do not want to use two include directives for the pari declarations. So one has to include the other in a way or the other (can be Perhaps the description is not clear enough. |
I honestly don't think that "parsing" the Sorry, but -1 to this idea. |
I can change the code to use a proper C parser. Not talking about the method: how would you solve having cypari2 working with different versions of Pari without this auto-generation? |
As explained in my recent e-mail, I would still auto-generate the declarations, but from the The advantage is that The disadvantage is that it only contains declarations for functions which have a GP interface, so we would still need to keep the old |
What is the point of keeping |
The main point would be to support packages which directly call the PARI library functions, without going through the
I think it would make sense to keep the declarations of the latest stable version there. Sure, there will be incompatibilities with PARI master. However, even if we put the correct auto-generated declarations there, there will still be incompatibilities with the code using those declarations. In other words, there are 3 places where the functions appear:
We can only control 2, so there is nothing we can do with incompatibilities between 1 and 3. If 1 and 3 are incompatible, I think it's pointless to worry whether 2 should be compatible with 1 and incompatible with 3 or the other way around. |
But then the function signatures must be correct!
I agree that it is pointless to worry about incompatibilities between 1 and 3 because whatever we do that would never work out. But we should definitely support user basis programs that have Cython code up to date with their Pari versions. It is even possible for user code to have programs compatible with both PARI master and PARI stable using macros. In other words, I strongly think that our declarations (point 2) should match whatever PARI version is to be encountered on the system (point 1)... which is what I was trying to achieve. |
Well, you should also definitely support user basis programs that have Cython code up to date with the latest stable PARI.
If user code does that, they are surely clever enough to not need the declarations from
if the declarations from |
Isn't it exactly what I said? "Their PARI version" meant "whatever PARI the users run".
If it is not particularly hard to write
If you think it is not worth it you can stop arguing ;-) For the sake of this pull request I propose to leave the question of |
I don't even see how to make your proposal works. There are a lot (> 100) of pari function calls in |
@jdemeyer All right. I came up with someting... I am compiling pari master to see whether it works also there. |
Build passes on pari master (and only got 12 doctest failures) |
I would say I'm rather on Vincent side here. As far as my first remarks are concerned, I would still cdef extern from paridecl.h just in case the other pxd file disappear, and extend the lambda hack to be more general maybe putting it in a separate "fix" method which could be extended with other needed hacks. |
I feel like this is true by accident and not something that we can/should rely on. Now if you could somehow get a guarantee from the PARI developers that they will stick with a very simply syntax for |
For the easy cases. If some package intends to be compatible with PARI stable, they can just use our declarations from cypari2. Now, whether such a package is compatible with PARI master is beyond our control. As I explained before, auto-generating a correct The hard case is where a package needs a function from PARI master which is different or non-existent in PARI stable. In this case, the package needs to special-case depending on the PARI version anyway (either it needs different code for PARI stable or it won't work at all on PARI stable). I think it's fine if cypari2 does not support that out of the box, since it is sufficiently easy for the user code to support that. |
@jdemeyer And what about the current pull request which at least allows to build cypari2 with pari master? (at |
Well, that is the approach that I meant, so I agree. However, it seems that you were not totally convinced and @jpflori wasn't either, so I felt that the discussion was not finished. If you are in Bordeaux, maybe this is something you could discuss with the PARI developers too. |
About the patch itself: I don't understand why you are blacklisting all the plotting functions. Those functions might actually be useful, especially in interactive environments where plotting makes sense. |
Because I got errors if I allow them. They were not supported before anyway. If you want to work on it, please open another pull request. |
I am indeed not convinced but I like much more the branch than the cypari2 master. In Bordeaux it is holidays until mid-September. I will definitely discuss it with Bill and Karim. In the mean time, it seems reasonable to me that we merge this PR. |
It's true that plotting has changed significantly since the latest stable PARI release. If you are getting errors, let's look at that later. |
@jdemeyer @defeo do you agree to merge this pull request? @jdemeyer A release is explicitely asked in Sage at https://trac.sagemath.org/ticket/23518. Could you make a new one (hopefully including this PR)? |
I just pushed a commit with a few fixes. Vincent: If you accept these, then this can be merged for me. |
Issue #27 shows that it will be impossible to support various pari versions without auto generating pari declarations. The branch is a proposal to have an autogenerated
cypari2/auto_paridecl.pxi
, generated from the PARI.h
files, which is automatically included incypari2/paridecl.pxd
via a Cythoninclude
directive.The branch makes cypari2 works with both pari 2.9.3 and pari master at
a8e4b6c46
.