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

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

[Octave-bug-tracker] [bug #45835] inconsistent behaviour of eval inside


From: anonymous
Subject: [Octave-bug-tracker] [bug #45835] inconsistent behaviour of eval inside anonymous functions
Date: Thu, 27 Aug 2015 14:23:44 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0

URL:
  <http://savannah.gnu.org/bugs/?45835>

                 Summary: inconsistent behaviour of eval inside anonymous
functions
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Do 27 Aug 2015 14:23:43 UTC
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.8.2
        Operating System: Microsoft Windows

    _______________________________________________________

Details:

Calling


f=@(t)eval('t');f(3)


produces


error: 't' undefined


So you could think the string is evaluated on the assignment of f. This is
confirmed by the following:


t=3;f=@(t)eval('t');f(2)


Which returns 3.
But if you type following, you see that the statement above is not true:


clear t;f=@(t)eval(num2str(t));f(42)


which returns 42.

In Matlab, the string within eval is only evaluated when f is called,
consistently.






    _______________________________________________________

Reply to this item at:

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

_______________________________________________
  Nachricht gesendet von/durch Savannah
  http://savannah.gnu.org/




reply via email to

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