bugGNU Octave - Bugs: bug #53331, Can't make function output...


bug #53331: Can't make function output argument persistent (poor man's constant)

Submitted by:  Oliver Heimlich <oheim>
Submitted on:  Mon 12 Mar 2018 08:52:25 PM UTC  
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  Kai Torben Ohlhus <siko1056>
Originator Name:  Oliver Heimlich Open/Closed:  Closed
Release:  dev Operating System:  Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Thu 22 Mar 2018 07:40:17 PM UTC, comment #10:

Thank you, works for me.


Thu 22 Mar 2018 07:36:24 PM UTC, comment #9:

Thanks Mike. I close this one.

Kai Torben Ohlhus <siko1056>
Project MemberIn charge of this item.
Thu 22 Mar 2018 06:19:10 PM UTC, comment #8:

Doc addition looks good to me, can we call this fixed?

Mike Miller <mtmiller>
Project Administrator
Wed 21 Mar 2018 09:49:19 PM UTC, comment #7:

For the docs, I added this one: https://hg.savannah.gnu.org/hgweb/octave/rev/11b13a7cc57e

Kai Torben Ohlhus <siko1056>
Project MemberIn charge of this item.
Wed 21 Mar 2018 09:27:18 PM UTC, comment #6:

Confirm comment #4. Matlab R2017b errors hard on functions like these: "The current use of 'x' is inconsistent with its previous use or definition (line 1)."

Thus close this item as "won't fix"?

Kai Torben Ohlhus <siko1056>
Project MemberIn charge of this item.
Sun 18 Mar 2018 10:05:23 AM UTC, comment #5:

I have fixed the interval package regarding this topic: https://sourceforge.net/p/octave/interval/ci/263b706e22ac22ca0c719aeca7fc86a9825c4d19/

Oliver Heimlich <oheim>
Tue 13 Mar 2018 04:59:14 PM UTC, comment #4:

I don't fully understand the underlying reasons either, but I guess that it may be described by jwe's comment

> I would prefer that we disallow making existing variables (including function parameters) global the same as we do for persistent

IOW, when the function definition is parsed, the output parameters are already "defined" in some sense as local variables? So then having a "persistent" statement overriding the output argument declaration is conflicting somehow.

And here is a quote from the Matlab official docs

> MATLAB also errors if you declare any of a function's input or output arguments as persistent within that same function

I think it would be helpful if this were mentioned in our docs, along with an example showing the correct way to do it.

Mike Miller <mtmiller>
Project Administrator
Tue 13 Mar 2018 08:42:48 AM UTC, comment #3:

Yes, the discussion in bug #52699 suggests that this change is intended. Yet, I still don't understand the reason for the change.

Oliver Heimlich <oheim>
Tue 13 Mar 2018 08:20:37 AM UTC, comment #2:

AFAIU, this change was intended. See e.g. the discussion in bug #52699.

Pantxo Diribarne <pantxo>
Project Member
Mon 12 Mar 2018 09:00:00 PM UTC, comment #1:

Confirmed, and it is a regression from 4.2.

Can be worked around with a simple no-cost copy of the constant to the return value:

Mike Miller <mtmiller>
Project Administrator
Mon 12 Mar 2018 08:52:25 PM UTC, original submission:

The following is a common(?) idiom in Octave to define a constant value: To define a function without parameters.

To prevent multiple initialization of a computed value, it can be made persistent. However, that fails in the current dev version.

I can understand that input(!) arguments cannot be made persistent. But, shouldn't that be possible for output arguments?

Oliver Heimlich <oheim>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by oheim (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-03-22 siko1056 StatusNeed Info => Fixed
        Open/ClosedOpen => Closed
    2018-03-22 siko1056 Assigned toNone => siko1056
    2018-03-21 siko1056 StatusConfirmed => Need Info
    2018-03-12 mtmiller StatusNone => Confirmed

    Back to the top

    Powered by Savane 3.3