Remove Bindgen Magic to Enhance Readability #15

Open
opened 2024-07-20 05:08:35 +00:00 by ThePerfectComputer · 3 comments
ThePerfectComputer commented 2024-07-20 05:08:35 +00:00 (Migrated from github.com)

This line seems to be enabled by bindgen!() magic... Such makes the codebase less readable. Can you re-factor this to get rid of bindgen!() magic, perhaps opting for something a bit more readable/maintainable such as let format_signal_value = instance.get_func(&mut store, "format_signal_value").unwrap().get1::<i32, i32>()?;?

[This line](https://github.com/JoyOfHardware/FastWave2.0/blob/main/src-tauri/src/lib.rs#L101) seems to be enabled by `bindgen!() ` magic... Such makes the codebase less readable. Can you re-factor this to get rid of `bindgen!()` magic, perhaps opting for something a bit more readable/maintainable such as `let format_signal_value = instance.get_func(&mut store, "format_signal_value").unwrap().get1::<i32, i32>()?;`?
ThePerfectComputer commented 2024-07-20 05:10:37 +00:00 (Migrated from github.com)

I'm not necessarily against Macros, but this crosses the line IMO. Things are now too hard to trace down for somebody reading/perusing the codebase.

I'm not necessarily against Macros, but this crosses the line IMO. Things are now too hard to trace down for somebody reading/perusing the codebase.
MartinKavik commented 2024-07-28 15:52:40 +00:00 (Migrated from github.com)

If I'm not wrong while looking at the code on my phone - the method called on that line is generated from the WIT component description by official Rust WIT component tools. The suggested changes would make it much less maintainable because it would ignore best WIT practices and it would break in case of WIT API changes because the macros make it verifiable by Rust compiler. However we can help the reader of the code by changing the component description itself to make the generated code more expressive or at least add some comments or other hints for the reader.

If I'm not wrong while looking at the code on my phone - the method called on that line is generated from the WIT component description by official Rust WIT component tools. The suggested changes would make it much less maintainable because it would ignore best WIT practices and it would break in case of WIT API changes because the macros make it verifiable by Rust compiler. However we can help the reader of the code by changing the component description itself to make the generated code more expressive or at least add some comments or other hints for the reader.
ThePerfectComputer commented 2024-07-31 16:47:03 +00:00 (Migrated from github.com)

This is understandable. Let me chew on this some more...

This is understandable. Let me chew on this some more...
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Products/FastWave2.0#15
No description provided.