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

gap_julia should check if julia_obj is an MPtr #22

Closed
fingolfin opened this issue Aug 21, 2018 · 8 comments
Closed

gap_julia should check if julia_obj is an MPtr #22

fingolfin opened this issue Aug 21, 2018 · 8 comments
Labels
topic: conversion Issue related to conversion

Comments

@fingolfin
Copy link
Member

... if julia_obj is not an MPtr, it should take appropriate steps, e.g. raise an error; or return NULL and then let call_gap_func check for NULL, and raise an error / return a suitable "fail" indicator.

@sebasguts
Copy link
Contributor

I would guess this should be an error then. Maybe try to convert it using the conversion function __ConvertedFromJulia_internal? Or would you think this is too implicit?

@fingolfin
Copy link
Member Author

Well, that goes back to the question I had yesterday: Why is ConvertedToJulia called automatically, but ConvertedFromJulia is not? What you are proposing seems to suggest to call that automatically, too.

Personally, I'd rather go the other way: I would not perform any conversion except the bare minimum (i.e. dealing with T_INT / T_FFE when going from GAP to Julia) in both directions; at least in the lowest level code. If automatic conversions are deemed desirable in some or all cases, then this could be implemented in a higher level. This way, at least the user a chance to bypass the automatic conversion in situations where this is beneficial.

@sebasguts
Copy link
Contributor

Yep, this seems reasonable.

sebasguts added a commit that referenced this issue Aug 22, 2018
@fingolfin
Copy link
Member Author

Ah, to clarify and finish that thought: if the input is a Julia object which is not an MPtr, or an T_FFE wrapper (or perhaps also a machine integer), then there is a choice between producing an error, or automatically wrapping it into a T_JULIA.

I think the latter is harmless and strictly superior to an error, as it is the bare minimum one needs to do.

A third option is to provide two functions: one which produces an error resp. wraps into a T_JULIA; the other automatically calls ConvertedFromJulia, for convenience

@fingolfin
Copy link
Member Author

All in all though, this is just theoretical wanking, it's best to start writing more complex code, and then seeing what one ends up needing. I.e. be ready to revise whatever decision is made now ;-)

@sebasguts
Copy link
Contributor

Currently, this function is really just used in a single case: Calling GAP functions from Julia. I think making the object a T_JULIA is the most sensible option here (just did not think about it beforehand). That way, one can actually somehow pass Julia Objects itself to GAP functions.

@sebasguts
Copy link
Contributor

This also means that we might want to use a different pattern in other places.

@fingolfin
Copy link
Member Author

indeed, and based on that, one can easily write a Julia function which first passes all arguments through ConvertedFromJulia, if so desired.

@fingolfin fingolfin added the topic: conversion Issue related to conversion label Jan 22, 2020
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

2 participants