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: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Regression
Status: FixedAssigned to: Kai Torben Ohlhus <siko1056>
Originator Name: Oliver HeimlichOpen/Closed: Closed
Release: devOperating 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 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 File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


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

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

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 22 Mar 2018 07:36:24 PM UTCsiko1056StatusNeed Info=>Fixed
    Thu 22 Mar 2018 03:28:54 PM UTCsiko1056Assigned toNone=>siko1056
    Wed 21 Mar 2018 09:27:18 PM UTCsiko1056StatusConfirmed=>Need Info
    Mon 12 Mar 2018 09:00:00 PM UTCmtmillerStatusNone=>Confirmed

    Back to the top

    Powered by Savane 3.1-cleanup1