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

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

[Octave-bug-tracker] [bug #47091] String representation of an anonymous


From: Rik
Subject: [Octave-bug-tracker] [bug #47091] String representation of an anonymous function may not match its semantics
Date: Tue, 09 Feb 2016 00:39:43 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0

Update of bug #47091 (project octave):

                  Status:                    None => Confirmed              
                 Release:                   3.8.2 => dev                    

    _______________________________________________________

Follow-up Comment #2:

This affects anonymous functions saved in binary format as well.

The issue is quite easy to see at the command line even without saving the
variable.


octave:36> f = @(m,n) 1 + m:n + 5
f =

@(m, n) 1 + m:n + 5

octave:37> f(1,2)
ans =

   2   3   4   5   6   7

octave:38> f = @(m,n) 1 + (m:n) + 5
f =

@(m, n) 1 + m:n + 5

octave:39> f(1,2)
ans =

   7   8


>From the second example you can see that Octave knows that 'm:n' is an atomic
unit, but it just isn't displayed that way.

Interestingly enough, for a definite range, i.e., values are fixed, the
parentheses are correctly added.


f = @(m,n) m + (1:4) + n
f =

@(m, n) m + (1:4) + n


I believe Octave walks it's own internal parse tree of the function in order
to print it.  It seems like it should be able to determine whether or not the
range is atomic and print the parentheses as necessary.


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?47091>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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