asar
asar copied to clipboard
Preventing user functions from overwriting builtins
As the title suggests, while rewriting asar_math's function handling code I corrected the bug where users could overwrite a builtin. This now generates an error.
Pros: Prevents users from making code that is accidentally misinterpreted. User may be trying to reimplement said builtin (especially math-like operators) not realizing it already existed Cons: Adding a new builtin has a small chance of being backward incompatible.
I personally believe the chances of such a name conflict are quite tiny and fairly trivial to correct should they happen. (either by renaming in asar or simply updating the patch.)
I feel like the best solution in this case is a warning: it doesn't make old patches incompatible, and it lets the user know of the builtin just as well as an error. You can also disable a warning if you know what you're doing.
A warning would be a good idea. Or if we decide to remove the feature altogether in the future, it would still be useful to have at least one release with a deprecation warning.
Should we keep user defined overwriting as an error or make it consistent with builtins?
"User defined overwriting"? As in, overwriting previously user-defined function?
I'd keep it consistent with the built-ins.
I would keep them as an error, since overwriting previously user-defined functions was never supported in the first place, and it can also lead to nasty problems if someone were to make some kind of shared code library or something like that, for example. Functions could overwrite other functions from the library. Of course we could throw a warning for that, but I think it's better to prevent users from doing that in the first place and throw an error. Can't think of a good reason to allow usage of a bad practice that wasn't usable before.
currently made overwriting either builtins or user functions a warning. not closing ths though since we didn't reach a consensus about overwriting user functions.
Warning + deprecation added to 1.9, error in 2.0, closing as completed.