-
-
Notifications
You must be signed in to change notification settings - Fork 223
Share
trait: deprecate + replace with Clone
#409
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
Conversation
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-409 |
Personally, I always thought it is nice that we have But I guess that's just what the ecosystem demands... |
I somewhat agree, which is why I added
What do you think about the arguments in #297 (comment) and following? |
I don't really have a strong opinion on this 😉 |
I suppose it depends on one's perspective. The data is shared by cloning the reference, but I understand the ambiguity. Personally, though, I'm not against having a |
I also thought making "sharing" explicit was nice -- but we can't fully escape that it is treated like a copy by Godot. # GDScript
let a: Type = [1, 2, 3]
let b = a # same syntax for copy _and_ share
# Type = PackedInt32Array -> copy
# Type = Array -> share Also in Rust: let a: VariantArray = varray![1, 2, 3];
let b = a.share();
// but:
let a = Variant::from(a);
let b = a.clone(); Same semantics, different method. The only thing I could possibly imagine is to have both:
But is Then there's also a question of expressing deep-copies somehow -- some Godot types have a This conundrum is not new either: godot-rust/gdnative#712 🙉 |
A couple of things that having These are ones i've stumbled upon wanting but not being able to use, like how do we properly clone a And several other similar methods that don't easily work with In addition having |
I agree that
|
Thanks for everyone's input. It seems like there is consensus that having As such, I'm going to merge this and deprecate |
Addresses part of #297.
What I'm not yet sure is whether the
impl Property
will still be needed forGd
,Array
andDictionary
, now that they support cloning.In a 2nd step, I would like to revisit the names of the
Gd
constructors. Some ideas:new_default
->with_init
,new
, ...new
->from_standalone
,from_object
,manage
, ...with_base
->from_base_fn
,from_base_ctor
, ...I don't want to implement
Default
for now due to the risk of manually managed types leaking.