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

cpp: isl::ctx implicit conversion to isl_ctx* #12

Open
nicolasvasilache opened this issue Aug 4, 2017 · 5 comments
Open

cpp: isl::ctx implicit conversion to isl_ctx* #12

nicolasvasilache opened this issue Aug 4, 2017 · 5 comments

Comments

@nicolasvasilache
Copy link

Memory management and lifetime of isl_ctx objects seems quite different from the ones that islpp automatically extracts. Let's not pretend the API should be the same (i.e. get, release etc), it feels more confusing than anything else.
From skimming through uses of isl::ctx it seems it is alway used with .release().
How about dropping all these raw pointer accessors and just implicitly convert to isl_ctx* ?

@tobiasgrosser
Copy link
Member

I like the idea. For backwards compatibility reasons (and consistency) I would likely not drop the existing interface, but adding an implicit conversion for isl_ctx * seems a straightforward and well justified change that certainly makes mixed C and C++ code a lot more readable.

Care to propose a patch?

@aisoard
Copy link
Collaborator

aisoard commented Aug 4, 2017

I prefer to be (overly) cautious about implicit conversions as this create surprising behaviors that will come back to bite us. That being said, the ctx object is almost never used in any expression, we rarely check it is non-null, and that is a lossless conversion. Which makes me think that is probably ok.

In any case, I agree that having get/release in the interface make little sense as isl::ctx does not actually manage the underlying isl_ctx.

Anyway, the isl_ctx is the black sheep of the family, I don't see any proper way of managing it as it is a transverse data-structure that isl does not handle. I would almost be ok with having a thread_local global isl_ctx, but I assume that would displease a lot of people. :-) (and that is an other unrelated discussion)

@ftynse
Copy link
Member

ftynse commented Aug 4, 2017 via email

@tobiasgrosser
Copy link
Member

Albert also mentioned that a ctx free (or thread-local only) use of the isl bindings would be great. It might make sense to make this a separate issue. (Seems very useful for scripting-style usage of these bindings)

@ftynse
Copy link
Member

ftynse commented Aug 4, 2017

Now it's #14

@tobiasgrosser tobiasgrosser changed the title isl::ctx implicit conversion to isl_ctx* cpp: isl::ctx implicit conversion to isl_ctx* Aug 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants