[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #45835] inconsistent behaviour of eval inside
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #45835] inconsistent behaviour of eval inside anonymous functions |
Date: |
Thu, 27 Aug 2015 21:17:39 +0000 |
User-agent: |
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1) |
Update of bug #45835 (project octave):
Status: None => Need Info
_______________________________________________________
Follow-up Comment #1:
Octave also waits to execute eval().
octave:1> f = @(t) eval ('t')
f =
@(t) eval ('t')
octave:2> eval ('t')
error: 't' undefined near line 1 column 1
octave:3> f (3)
error: 't' undefined near line 1 column 1
octave:4> t = 5
t = 5
octave:5> eval ('t')
t = 5
octave:6> f (3)
t = 5
In this case, 't' is a string and is not subject to variable replacement in
the anonymous function.
In your second case, t is not used as a string but as a variable.
f = @(t) eval (num2str (t))
is truly equivalent to
tmp = num2str (t)
eval (tmp)
One can verify that the eval is taking place because the return value of
num2str is a char variable, but the return value of the anonymous function f
is a double value which only happens because a string like "42" has been
eval'ed.
class (f (42))
ans = double
If you have access to Matlab, what does it return for the following?
clear all;
f = @(t) eval ('sin (t)');
f(1)
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?45835>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #45835] inconsistent behaviour of eval inside anonymous functions, anonymous, 2015/08/27
- [Octave-bug-tracker] [bug #45835] inconsistent behaviour of eval inside anonymous functions,
Rik <=
- [Octave-bug-tracker] [bug #45835] inconsistent behaviour of eval inside anonymous functions, Mike Miller, 2015/08/27
- [Octave-bug-tracker] [bug #45835] interpreter does not search for anonymous function variables within a string, Rik, 2015/08/27
- [Octave-bug-tracker] [bug #45835] interpreter does not search for anonymous function variables within a string, John W. Eaton, 2015/08/28
- [Octave-bug-tracker] [bug #45835] wrong scope may be used in anonymous function evaluation, John W. Eaton, 2015/08/28
- [Octave-bug-tracker] [bug #45835] wrong scope may be used in anonymous function evaluation, John W. Eaton, 2015/08/28
- [Octave-bug-tracker] [bug #45835] wrong scope may be used in anonymous function evaluation, John W. Eaton, 2015/08/29
- [Octave-bug-tracker] [bug #45835] wrong scope may be used in anonymous function evaluation, Rik, 2015/08/29
- [Octave-bug-tracker] [bug #45835] wrong scope may be used in anonymous function evaluation, Rik, 2015/08/29
- [Octave-bug-tracker] [bug #45835] wrong scope may be used in anonymous function evaluation, Rik, 2015/08/30