Re: PR 7536 - ``set input-radix 1'' changes radix

Pedro Alves
2008-12-29T19:31:05Z

On Monday 29 December 2008 19:11:17, Tom Tromey wrote:

> I also looked at this bug a little, and I was wondering whether we
> should fix this generically, for all parameters, by saving the
> parameter's value and then restoring it if the setter function raises
> an error. What do you think of that?

That's actually something that crosses my mind everytime I
touch these set/validate functions.

There are a couple of corner/tricky case that you would have to consider
like QUIT (pagination makes that easy-ish to trigger), and the fact that
it can happen before or after the setter having already done
side effects; or, an error not meaning the setting didn't take effect.
A codebase audit would probably be required to make sure side effects
are unwound correctly, but it's probably doable. Another option would
be to pass to the setter the new alreayd parsed value, and let it validate
and set the final variable itself --- the setter code always knows what
it it setting. The issue is that you either pass a variant, or have
a different setter function type for each type of variable.

--
Pedro Alves