finale-lua / lua-scripts

A central repository for all Lua scripts for Finale.
https://finalelua.com
Creative Commons Zero v1.0 Universal
15 stars 14 forks source link

Potential Windows bug for user settings? #342

Open Nick-Mazuk opened 2 years ago

Nick-Mazuk commented 2 years ago

When looking through the user settings source code, I noticed that the get_parameters_from_file uses calc_preferences_filepath directly:

https://github.com/finale-lua/lua-scripts/blob/c04293031839b6d18759f5d0035c7522c4466edd/src/library/configuration.lua#L268-L270

Yet calc_preferences_filepath returns a tuple:

https://github.com/finale-lua/lua-scripts/blob/c04293031839b6d18759f5d0035c7522c4466edd/src/library/configuration.lua#L205-L222

This seems to be working fine on macOS, but it seems like a strong code smell. Is this working on Windows?

Either way, I'd suggest rewriting it to destructure the tuple first, then only use the first value. While this seems to be acceptable Lua code, this would not be acceptable code in many other languages and could confuse many other people (including me at first).

rpatters1 commented 2 years ago

Lua functions can return multiple values without the callers having to consume them. It isn't a "tuple" in the C++ sense. It is two discrete values.

Is there a reason to think it would fail on Windows? It seems like bog-standard Lua to me.