octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #59192] unwind_protect objects should be repla


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #59192] unwind_protect objects should be replaced with lighter weight alternatives
Date: Mon, 28 Sep 2020 14:14:53 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0

Follow-up Comment #10, bug #59192 (project octave):

Rik: Yeah, me too.  But there are things like this (just an example, not real
code):


unwind_protect frame;

frame.protect_var (v1);
v1 = some_value;

frame.add_fcn (some_fcn, ...);

frame.protect_var (v2);
v2 = some_other_value;

if (some_condition)
  {
     frame.add_fcn (another_fcn, ...);

     do_some_stuff ();
  }


I could guess but wouldn't know for sure without doing some careful checking
whether it would be OK to rearrange the order in which things are
saved/restored (actual code might be much more complex than the bit above). 
In some cases it may be OK to create a new unwind_action inside an inner scope
(see the use of another_fcn above) and others adding it to the unwind_protect
object is simply conditional and the action needs to execute at the end of the
outer scope.  So we might need to be able to write something like this:


unwind_action act;

if (condition)
  act = unwind_action (...);

// OR (perhaps to avoid confusion?)

if (condition)
  act.replace_action (...);


Copying unwind_action objects is currently not allowed, probably because doing
so could cause some confusion.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?59192>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]