[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `argn' ? … still part of Octave?
From: |
John W. Eaton |
Subject: |
Re: `argn' ? … still part of Octave? |
Date: |
Wed, 5 Oct 2011 22:56:07 -0400 |
On 5-Oct-2011, Ben Abbott wrote:
| 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?
Yes, because argn is a character array (I don't know why, but I
thought it was a cell array of character strings).
So look at argn, not argn(1:nargin)
Ah, now I see, the real internal variable that holds the argument
names is a special hidden variable called ".argn." that is only
accessible with __varval__ (".argn.").
These aren't really things that people are expected to be playing
around with, but are there to help with implementing Octave itself.
I'd probably hide them completely except that the scoping rules make
that kind of hard, I think.
jwe
- Re: `argn' ? … still part of Octave ?, (continued)
- Re: `argn' ? … still part of Octave ?, Ben Abbott, 2011/10/23
- Re: `argn' ? … still part of Octave?, Carnë Draug, 2011/10/24
- Re: `argn' ? … still part of Octave ?, Ben Abbott, 2011/10/24
- Re: `argn' ? … still part of Octave?, Carnë Draug, 2011/10/24
- Re: `argn' ? … still part of Octave ?, Ben Abbott, 2011/10/24
- Re: `argn' ? … still part of Octave?, Carnë Draug, 2011/10/25
- Re: `argn' ? … still part of Octave ?, Ben Abbott, 2011/10/25
- Message not available
- Message not available
- Re: `argn' ? … still part of Octave?, Carnë Draug, 2011/10/26
- Re: `argn' ? … still part of Octave?,
John W. Eaton <=
- Re: `argn' ? … still part of Octave?, Carnë Draug, 2011/10/06
- Re: `argn' ? … still part of Octave?, John W. Eaton, 2011/10/06