octave-maintainers
[Top][All Lists]
Advanced

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

Re: `argn' ? … still part of Octave ?


From: Ben Abbott
Subject: Re: `argn' ? … still part of Octave ?
Date: Wed, 05 Oct 2011 08:28:44 -0400

On Oct 5, 2011, at 12:07 AM, John W. Eaton wrote:

> On  4-Oct-2011, Ben Abbott wrote:
> 
> | I noticed in the doc string for "whos" that "argn" is mentioned ...
> | 
> | "Automatic variable.  An automatic variable is one created by the 
> interpreter, for example `argn'."
> | 
> | Is "argn" still a part of Octave, and if so, what is its function?
> 
> It's like inputname, but it can return something even if the argument
> was an expression.
> 
> jwe

Thanks. I asked because of the bug reported below.

        https://savannah.gnu.org/bugs/?34478

Apparently, "argn" isn't working for the private functions for @-style objects.

Playing a bit, I noticed some unexpected behavior (I was curious how argn 
compared with inputname())

function varargout = fubar (varargin)
  varargout{1} = argn(1:nargin);
  for n = 1:nargin
    varargout{2}(n) = {inputname(n)};
  endfor
endfunction

a = 1; b = 2; c = 3; d = 4;

[args, inputs] = fubar(a, b, c, d)
args =

a
b
c
d

inputs = 
{
  [1,1] = a
  [1,2] = b
  [1,3] = c
  [1,4] = d
}

[args, inputs] = fubar(a, b, a*b, c, d)
args = abacd
inputs = 
{
  [1,1] = a
  [1,2] = b
  [1,3] = 
  [1,4] = c
  [1,5] = d
}

In this second case, both argn and inputname() seem to display bugs. Is my 
inference correct?

Ben



reply via email to

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