oooutlk / tcltk

Rust bindings to Tcl/Tk commands
Apache License 2.0
18 stars 3 forks source link

Usability suggestion for canvas delete and bbox methods + after and destroy functions #14

Open mrtodd opened 6 months ago

mrtodd commented 6 months ago

One of the first difficulties I had when using this crate was trying to figure out how to destroy a widget. Somehow using a tuple to represent an arbitrary number of widgets (including a solitary one) to be deleted was not near the top of my list of things to try. It seems to me that instead of forcing the HomoTuple construct on the user, it might be better to present an interface that allows the user to supply arguments that are a bit more intuitive. What I have done in the case of the functions/methods listed in the title is change the argument for the TagOrId, Widgets, Scripts only to require Into<Obj>. I think this change will not effect any existing application code, but will allow the user to specify just a single tag, widget or script command if they don't require a collection of items. As a bonus a Vec (which is what first comes to mind for me when trying to represent an arbitrary number of items) will also be accepted if a collection is required.

I have included a list of the differences in the attached file (the change shown for 'tcl/src/obj.rs' can be ignored) if you care to consider my suggestion.

-- Todd

diffs.txt

oooutlk commented 6 months ago

Thanks for your suggestion to improve ergonomics. I will accept it in the next version.

When I began to write version 0.1.0, I consider it as an experimental project and introduced several experimental features. One of them is NonZeroLen which ensures provided tcl objects are not empty at compile time. That's why HomoTuple is involved. However it is more confusing than Into<Obj> way, as you said.