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

Default deleteOriginal to true #700

Closed
HosseinYousefi opened this issue Nov 18, 2022 · 4 comments
Closed

Default deleteOriginal to true #700

HosseinYousefi opened this issue Nov 18, 2022 · 4 comments

Comments

@HosseinYousefi
Copy link
Member

I wonder if deleteOrignal should default to true. If you're casting it's likely that you're only using the new casted value afterwards.

Originally posted by @dcharkes in dart-archive/jnigen#136 (comment)

@dcharkes
Copy link
Collaborator

Cross linking issues:

@HosseinYousefi
Copy link
Member Author

I think deleteOriginal should remain false by default.

Rationale:

  1. It's really weird for a new user to face something like when there is no explicit release happening.
JString s = ...;
final a = '${s.toDartString()}A';
// so far so good! but later they add:
final b = '${s.toDartString()}B'; // Error! Use after free...
  1. Users don't have to delete the original object, it's only going to be slightly less efficient since we're creating a new global reference.

However deleteOriginal or even releaseOriginal is a bit verbose, so maybe we can come up with a shorter name like convert: true (Not exactly this one).

@HosseinYousefi
Copy link
Member Author

Alternatively, we could add two methods for each kind:

  • toDartString(), castTo, ... would keep the original:
  • asDartString(), castAs, ... would release it

Maybe to and as are confusing though...

@HosseinYousefi
Copy link
Member Author

Closing as deleteOriginal or releaseOriginal after the rename will stay false by default.

@HosseinYousefi HosseinYousefi transferred this issue from dart-archive/jnigen Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants