[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: More format() changes
From: |
Rik |
Subject: |
Re: More format() changes |
Date: |
Wed, 16 Oct 2019 09:30:14 -0700 |
On 10/16/2019 09:11 AM, John W. Eaton wrote:
> On 10/16/19 11:16 AM, Rik wrote:
>
>> Alternatively, we could use Octave's own unwind_protect
>> class and the protect_var method, but I'm not sure if that does what we
>> want in this instance which is to let the change happen, unless an error is
>> thrown, in which case the variable needs to be restored.
>
> This approach is probably the simplest thing and most like other code in
> Octave that needs to reset some internal program state on an error. To
> prevent the changes from reverting if there is no error, you can discard
> the actions of an unwind_protect object. I think the attached patch
> should do it.
>
> It would be a little easier if all format settings were stored in a
> single object instead of as individual file-scope or global variables.
> I'm headed in that direction anyway, as I think all this info should be
> stored as part of the interpreter object instead of globally, but that's
> a project for another day.
I completely agree about encapsulating all of these bits of information in
a single object for ease of use, and also that I don't have time for that
just now. Let me take a look at your diffs and understand it, and then
I'll check it in.
--Rik