bugGNU Octave - Bugs: bug #45682, str2func should accept '@(x) x^2'...

 
 

bug #45682: str2func should accept '@(x) x^2' for matlab compatability

Submitted by:  Jeff Fessler <professler>
Submitted on:  Mon 03 Aug 2015 06:50:37 PM UTC  
 
Category: Octave FunctionSeverity: 1 - Wish
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: Jeff FesslerOpen/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.

 

Wed 23 Sep 2015 09:40:39 AM UTC, comment #4:

Fixed on the development branch in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/df7d34a1c7e6).

Rik <rik5>
Project Administrator
Mon 10 Aug 2015 03:42:56 AM UTC, comment #3:

In the meantime, I changed the documentation on the stable branch to note that anonymous functions are not supported and that the preferred workaround is

The changeset for that is here http://hg.savannah.gnu.org/hgweb/octave/rev/8fcbb55745ef.

On the development branch, I added a check for anonymous functions and it issues an error now (http://hg.savannah.gnu.org/hgweb/octave/rev/82712ed1be68).

This is just a partial fix until someone can figure out how to essentiall call 'eval (str)' from the C++ code in ov-fcn-handle.cc.

Rik <rik5>
Project Administrator
Mon 03 Aug 2015 08:27:14 PM UTC, comment #2:

yes i think that is all that is needed.
if str2func were an m-file i would have offered a fix but it is a built-in function and modifying those is beyond my know how...

Jeff Fessler <professler>
Mon 03 Aug 2015 07:11:56 PM UTC, comment #1:

Thanks for the report. So basically, if str starts with "@", then str2func(str) returns exactly the same thing as eval(str)? This looks pretty simple to add to Octave.

Mike Miller <mtmiller>
Project Administrator
Mon 03 Aug 2015 06:50:37 PM UTC, original submission:

Matlab is going to phase out inline in future releases
http://www.mathworks.com/help/matlab/ref/inline.html

But there are still situations where one must create a function from a string and "strfunc" is the way to do that.

In Matlab, the following code bit makes a useful function handle:

whereas octave (3.8.2) returns the following error message:

For compatibility it would be useful if Octave also supported that usage of str2func().

Jeff Fessler <professler>

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by professler (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 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 02 Feb 2016 09:31:58 PM UTCmtmillerDependencies-=>bugs #47046 is dependent
    Wed 23 Sep 2015 09:40:39 AM UTCrik5StatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Mon 03 Aug 2015 07:11:56 PM UTCmtmillerSeverity3 - Normal=>1 - Wish
      StatusNone=>Confirmed
      Release3.8.2=>dev

    Back to the top


    Powered by Savane 3.1-cleanup1