You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The text was updated successfully, but these errors were encountered:
chitoyuu
changed the title
Generated code depends on Variant::to which is only available under feature convenience
Generated code depends on functions only available under feature convenienceJan 8, 2023
Originally the intention of convenience (possibly to be renamed as yolo 😀) was that someone who wants to be aware of fallible operations can disable that feature and the number of panicking functions will be drastically reduced.
That said, I'm not sure if there are people truly wishing for that or if it's something we want to encourage as a best practice, as it has two notable downsides:
Verbosity of code that never fails due to external invariants.
E.g. scene tree has a certain structure, so getting a node of a given name/type must succeed or it's a bug.
If I know the value on GDScript side fits into a u8, then to_variant()must succeed or it's a bug.
Worse error messages.
People tend to use unwrap() or expect("literal"), which lacks context information.
get_node_as::<T>("path") on the other hand can include a precise panic message, e.g. "there is a node at path path with type U, but type T was requested".
Maybe I'll remove this feature but keep the commented-out #[cfg] statements around in case we want to re-introduce it later. Keeping it may add quite some maintenance overhead which is probably not justifiable at this stage of the library.
Screenshot from hapenia on Discord:
The text was updated successfully, but these errors were encountered: